Re: [sqlite] how to get the INTEGER PRIMARY KEY for the row just inserted?

2005-04-07 Thread Dennis Cote
Jay wrote: Oh. Nifty. I would therefore be safe doing this: begin immediate; insert into master_table() values(); insert into related_table( master_id, data ) select last_insert_rowid(), 'stuff'; commit; But it would fail if I had multiple related tables? begin immediate; insert into

Re: [sqlite] how to get the INTEGER PRIMARY KEY for the row just inserted?

2005-04-06 Thread Jay
> >>begin immediate; insert; select max(id) from blah; commit; > >> > >> > > > >Or "select last_insert_rowid() from blah limit 1" > > > >Regards > > > > > > > Better yet > > select last_insert_rowid(); > > The from clause is not needed and may imply that SQLite keeps the > last >

Re: [sqlite] how to get the INTEGER PRIMARY KEY for the row just inserted?

2005-04-06 Thread Dennis Cote
Kurt Welgehausen wrote: begin immediate; insert; select max(id) from blah; commit; Or "select last_insert_rowid() from blah limit 1" Regards Better yet select last_insert_rowid(); The from clause is not needed and may imply that SQLite keeps the last inserted rowid for each table,

Re: [sqlite] how to get the INTEGER PRIMARY KEY for the row just inserted?

2005-04-05 Thread Kurt Welgehausen
> begin immediate; insert; select max(id) from blah; commit; Or "select last_insert_rowid() from blah limit 1" Regards

Re: [sqlite] how to get the INTEGER PRIMARY KEY for the row just inserted?

2005-04-05 Thread Jay
The documentation is your friend. long long int sqlite3_last_insert_rowid(sqlite3*); http://sqlite.org/capi3ref.html#sqlite3_last_insert_rowid or begin immediate; insert; select max(id) from blah; commit; --- jack wu <[EMAIL PROTECTED]> wrote: > i have a table which has an ID column defined

[sqlite] how to get the INTEGER PRIMARY KEY for the row just inserted?

2005-04-05 Thread jack wu
i have a table which has an ID column defined as INTEGER PRIMARY KEY. I'd like to know the value of the automatically generated ID right after the insert. is there anyway to get the ID without issuing another select? does the insert function return the ID in any way? if another select is