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
> >>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
>
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,
> begin immediate; insert; select max(id) from blah; commit;
Or "select last_insert_rowid() from blah limit 1"
Regards
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
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
6 matches
Mail list logo