On Sun, 25 Mar 2012 18:10:14 +0800, Neo Anderson <neo_in_mat...@msn.com>
wrote:

>
> Is it possible to handle multiple results using sqlite3_step or any other API 
> calls?
>
> I want to execute the following SQL in one statement and want to get the two 
> resultsets.
>
> select 1 a; select 2 b;

(that doe not look like valid SQL)

No, you can't, at least not using the API.

If you prepare() that compound statement, only the first select will be
compiled, return a prepared statement pointer and update the string
pointer to the remainder (everything after the ';').

Another call of prepare() is needed to compile the second half.
Now you have two prepared statements, and step() has to be related to
one of them, so you have two different step() calls.

You can, however, do something similar with SQL:

SELECT 1 AS o,a AS v FROM tbla
UNION
SELECT 2 AS o,b AS v FROM tblb
ORDER BY o,v;

prepare() will compile that to one prepared statement, and you can
step() over the result rows.


-- 
Regards,

Kees Nuyt

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to