On Tue, May 7, 2013 at 7:14 AM, Mikael <mikael.tr...@gmail.com> wrote:
> A generalized way of getting if an ID was inserted on the last performed
> query and if so which, is of value for instance when inserting a row into a
> table with an AUTOINCREMENT key e.g.

This can get tricky if you have BEFORE INSERT triggers that insert
rows in other tables and then RAISE(IGNORE).  Of if the table is a
VIEW with an INSTEAD OF INSERT trigger that does something similar.  A
last rowid function might... return nothing (inserts/updates done in
trigger bodies not exposed) or it might show you the last rowid
touched by the trigger -- either way it's not what you'd want.

If the one INSERT turns into any number of inserts (or updates! or
deletes!) other than 1, then what?

For me the best thing to do here is to just do your INSERTs and
UPDATEs and then SELECT to find the results.  If you must then do a
SELECT after each INSERT/UPDATE to find out what you got.  This works
whether there's triggers or not.

Nico
--
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to