Stephen Sutherland [mailto:[EMAIL PROTECTED] wrote:
> 
> Thanks this is great information on sqlite's prepared statements.
> 
>   I think I have just one more question on this subject.
> 
>   I need to execute a SQL statement like this:
>   "SELECT * FROM tbl WHERE BookID IN ( :arrayNumbers) ;"

If you want to pass a variable number of items in, you won't be able to
use a single placeholder; each placeholder is replaced by a single
value, not a list.

>   My function will be receiving an array like this
> 
>   void getVariableBookIDs( int arraynumbers[], int alength )
>   {
> 
>        // what's the best technique pass these array of numbers to the
> query?
>        // can I use prepared statements ?
>        // I won't be doing this too often - like within a tight loop
so a
> regular sqlite3_exec would work as well.
>   }

I'd dynamically cook up a string with a suitable number of parameters,
prepare it, and bind each in a loop before sqlite3_step()'ing though the
results.  (If this was done frequently then you could cache the prepared
statements.  If not, it's likely not worth the small amount of added
complexity.)

-- James


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to