On Fri, Jul 3, 2015 at 6:16 PM, Kumar Suraj <surajnitk at gmail.com> wrote:

> So whats the solution here. I am giving 4 statements because i need insert
> to be transactional.


You need to prepare() 4 statements or, like Clemens suggests, use exec()
where possible instead of prepare/step.

Some other process could be inserting in the same db
> and so we need insert and row id values to be in one transaction.  Is there
> any other way i can achieve it.


Simplest, i think, is something like this pseudocode:

exec("BEGIN;");
prepare("INSERT...;");
bind(...)
step(...);
finalize(...);
id = sqlite3_last_insert_rowid(...);
exec("COMMIT;");

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf

Reply via email to