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) ;" 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. } Thanks in Advance. Stephen
Eugene Wee <[EMAIL PROTECTED]> wrote: > How can I do the same with prepare statements ? > Is it possible for me to prepare 10,000 in a loop and then surround them with > BEGIN TRANSACTCION AND END TRANSACTION ? Yes. As an added benefit the preparation would mean that the SQL statement does not have to be parsed on each iteration of the loop. > Actually I would appreciate a little code sample, if possible . This is a C++ example that does not do any error checking: // Assume db is the database handle and stmt is the statement handle. sqlite3_exec(db, "BEGIN TRANSACTION;", 0, 0, 0); sqlite3_prepare_v2(db, "INSERT INTO foo (bar) VALUES (:bar);", -1, &stmt, 0); for (int i = 0; i < 10000; ++i) { sqlite3_bind_int(stmt, 1, i); // Bind i to the first parameter. sqlite3_step(stmt); // Execute the statement. sqlite3_reset(stmt); } sqlite3_finalize(stmt); sqlite3_exec(db, "COMMIT TRANSACTION;", 0, 0, 0); Regards, Eugene Wee ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] ----------------------------------------------------------------------------- --------------------------------- Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV.