Yes, I am well aware of this possibility as I've written in my initial mail. It just doesn't fit with the description of sqlite3_last_insert_rowid() in my understanding. I think this is a bug - either in the documentation or in the implementation. sqlite3_last_insert_rowid() should return the correct id, no matter what and it doesn't.
Since I have a bunch of tables of this structure I don't want to waste memory/processor time just to retrieve the rowid I should have gotten in the first place from the insert. Mike -----Ursprüngliche Nachricht----- Von: Kees Nuyt [mailto:[EMAIL PROTECTED] Gesendet: Sonntag, 28. Oktober 2007 15:36 An: sqlite-users@sqlite.org Betreff: Re: AW: [sqlite] INSERT OR IGNORE and sqlite3_last_insert_rowid() [Default] On Sun, 28 Oct 2007 10:00:52 +0100, "Michael Ruck" <[EMAIL PROTECTED]> wrote: >Hi, > >I did specify UNIQUE for category. The id is also kept, so everything >is working >*except* that I don't get the id of the record ignored from >sqlite3_last_insert_rowid(). > >Mike You could simply do a SELECT id FROM categories WHERE category = '<yourvalue>'; to retrieve the id. After the (ignored) INSERT the database pages with the relevant parts of the BTree for the UNIQUE index on category will still be in memory, so the SELECT will be fast. For even more speed you can prepare the SELECT statement during the init of your program, and bind to the appropriate values every time you need it, so it doesn't have to be parsed every time. Regards, -- ( Kees Nuyt ) c[_] ---------------------------------------------------------------------------- - To unsubscribe, send email to [EMAIL PROTECTED] ---------------------------------------------------------------------------- - ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------