Olaf Beckman Lapré wrote:
No, that's not the case since I'm using an AUTOINCREMENT key and I can't
know the value of the key until the INSERT is completed.
Olaf
----- Original Message -----
From: "John Stanton" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Monday, July 24, 2006 5:30 PM
Subject: Re: [sqlite] Getting callback with an INSERT
It hardly seems necessary to make it a callback since you could just
call your function concurrently with the INSERT SQL.
Olaf Beckman Lapré wrote:
Is it possible to get a callback when doing an INSERT on a table similar
to a SELECT callback? The callback would then contain the same parameters
but only contain the row(s) being inserted.
The reason I'm asking is that this may be usefull in GUI applications
where you insert table rows into a listcontrol. Instead of emptying the
listcontrol and using the SELECT callback to fill it again, one could simply
add the row being added from the INSERT callback.
Olaf
There is an API call sqlite3_last_insert_rowid(..) which gives you the
rowid after the insert. Here is a code fragment using it.
....
if (bind_txt_arg(dbcmp_bchreg_ins, 7, bchr->bch_type)) return(TRUE);
/*Now we execute the SQL statement in a single step.*/
sqlite3_step(dbcmp_bchreg_ins); /*Executes compiled SQL.*/
rc = sqlite3_reset(dbcmp_bchreg_ins); /*Ready for next access.*/
if (rc == SQLITE_DONE) bchr->rowid = sqlite3_last_insert_rowid(db);
else {
sqlite_step_check(rc, fnm);
rollback_db_trans(trnm);
SetEvent(db_sync);
return(-1);
} /*if/else*/
....