in reply to Sequences, last_insert_id, SQLite, and Oracle
In SQLite:
In Oracle, assuming you have setup a trigger to emulate the auto_increment feature:insert into table ... select last_insert_rowid();
Note that you have to name your sequence predictably based on the table name to do that. We just append "_seq" to the table name to get the sequence name.insert into table ... select table_seq.currval from dual;
If you *really* want to be clever, you could set up an oracle package to contain a global session variable, and then make all your auto_increment-emulation triggers update that variable. Then you can write a last_insert_rowid() function to return that value. But you still need the "from dual" in oracle, so the sql is still different.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sequences, last_insert_id, SQLite, and Oracle
by etcshadow (Priest) on Jun 15, 2005 at 01:20 UTC | |
by sharkey (Scribe) on Jun 17, 2005 at 04:28 UTC |