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]
-----------------------------------------------------------------------------

Reply via email to