Hello,

> There ain't and there can't be. LAST_INSERT_ID is a
> non-standard SQL
> extension. Some databases support equivalent mechanisms but
> not all

Actually this is not really correct.

All databases have some methods for creating sequences. Sometimes this
auto_increment sometimes these are sequences.

For example, libdbi (that has even wider DB support then soci)
Supports it:
http://libdbi.sourceforge.net/docs/programmers-guide/reference-query.html#DBI-CONN-SEQUENCE-LAST

There where discussions on mailing list in past and at some point I
wanted to implement this feature, but I had not time to work on it.

There are few problems:

a) Some databases provide API to get last-insert-id, MySQL, Sqlite3
b) Some databases provide API to get last-id of specific sequence: PostgreSQL, 
MS SQL, Oracle if I do not mistake.
c) Some allow to get next id for specific sequence: Firebird (that
   does not have sequences at all).

So there should be a set of functions or something like:

sql << "insert ..." , use(a), ... , into(sequence_id("sequence_name",id))

Where for MySQL, SQlite sequence is ignored,
for Postgresql, Oracle and MS SQL it is fetched *after* the statement
and for firebid it is fetched **before** insert statemet.

Artyom.




      

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to