I was wondering what possible reasons the following query to fail on a
certain code path but not from another. When I check the database after
this function is called, from a one code path the database updates, from
the other code path the database does not update. Important to note is
that in both cases the sqlite3_last_insert_rowid(db) call returns the
correct value. This is being done through the sqlite3 C library. This is
a shared library that is being called from a UI application.

INSERT into aaa (b) values (1)

The code of the function is as follows:
char * sql_insert = "INSERT into aaa (b) values (1)";
sqlite3_stmt * statement_insert = 0;
int j= 0;

j = sqlite3_prepare_v2(db, sql_insert, -1, &statement_insert, NULL);
if(j!=SQLITE_OK){ goto err; }
j= sqlite3_step(statement_insert);
if(j!=SQLITE_DONE){ goto err; }

err:
if(statement_insert){ sqlite3_finalize(statement_insert); }


return sqlite3_last_insert_rowid(id);



The schema for the table:

CREATE TABLE aaa (
a integer not null primary key,
b blob not null,
c integer not null default 0,
d integer not null default 0,
insert_time data
);
CREATE TRIGGER bb after insert on aaa
begin
update aaa set insert_time= strftime('%Y-%m-%d %H:%m:%f', 'now','utc')
where id = new.id;
end; 


Thanks in advance,

Ben 

Reply via email to