All you need to do is to test the returned status of your sqlite3_step
calls and if you get an error launch an SQL statement "ROLLBACK" and
bail out of the transaction. If there are no errors you complete your
transaction with an SQL "COMMIT".
sqlite_prepare_v2 SQL statements
exec BEGIN
count = 0;
while ((count < MAX) && !error) {
rc = sqlite3_step SQL statement[count++];
if (rc != SQLITE_OK) {
error = TRUE;
}
}
if (error) exec ROLLBACK
else exec COMMIT
d_maniger06 wrote:
good day!..
i have a list of records that i want to insert in my database..if ever an
error occurred ( e.g. insert was not successful ), i want to undo all the
previous inserts that i have done..to do this, i have read that i would need
to use sqlite3_commit_hook and sqlite3_rollback_hook..i have read their
descriptions in the sqlite site, but i really can't understand it..im just a
newbie in sqlite by the way..i also have tried searching sample c codes that
does these things but i really cant find any..
i would just like to request a simple sample code demonstrating on how to
use these two apis..if it is ok also, please leave a very brief explanation
on what happened in the code..
thank you and God bless!.. :working:
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------