Thx for hint.

I see also the RSmith contribute.

This is not only impossible in the current SQLite implementation, it is also 
inconceivable.  By that I mean that the query output
can be of any form, there is no way a prepare statement can know before-hand 
what the query would look like, it might not even be a
SELECT as you point out.  Let's say the format issue is overcome, whereto will 
errors in the secondary query be reported? And would
the secondary query be able to refer to another in-table-pre-saved query? If so 
a infinite loop may quickly arise.

You could of course implement it given you know exactly what to expect from the 
Queries, I believe it is even done somewhere - but
you'd have to do something like this (pseudo coded for brevity):

Effectively the most useful usecase scenario for an EXECUTE is when
the queries are to build other tables and insert into them.

AFAIK if the dynamic queries are CREATE, INSERT , DELETE.
They return always 1 only value.
I guess a SELECT query is not so useful in a dinamical scenario but if needed the select query could have its records redirected on a third table to allow return from the EXECUTE always 1 only value (1/0 - successful/unsuccesful).

Many thx,

Andrea Peri.


On 17/04/2014 20:47, Richard Hipp wrote:



On Thu, Apr 17, 2014 at 2:43 PM, aperi2007 <aperi2...@gmail.com <mailto:aperi2...@gmail.com>> wrote:

    Hi to all,

    There is in sqlite a command to run a query build at runtime ?



Not built-in. But you can add your own. See http://www.sqlite.org/src/artifact/d3013ce36f19ac72?ln=289-319 for an example function that does this that we use for testing.


    Our use-case is a list of query build from a sql script and stored
    in a table.

    something like this:

    select EXECUTE([field_query]) from table1;

    where "table1" is the table and "field1" is the field where the
    builded query was previous stored.

    the queries could be of kind "create ...", "insert ...", "update
    ...." and so on.

    Thx,

    Andrea Peri.

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




--
D. Richard Hipp
d...@sqlite.org <mailto:d...@sqlite.org>

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

Reply via email to