Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How do you genrate primary keys?
Oracle has "RETURNING" clause for insert.
Igor Neyman, OCP DBA
ineyman_at_perceptron.com
-----Original Message-----
Stefan Jahnke
Sent: Monday, November 10, 2003 10:34 AM
To: Multiple recipients of list ORACLE-L
Hi Rachel
In most Java applications I've seen so far, the issue of caching rows by
an
id, which is usually the primary key, arises. JDBC v3 implements a
method
which allows you to return a key after the insert completed (for example
MS
SQL Server can do this). How do you get a hold of the PK, after you
inserted
the key via trigger without an extra roundtrip ?
Regards,
Stefan
-----Ursprüngliche Nachricht-----
Von: Rachel Carmichael [mailto:wisernet100_at_yahoo.com]
Gesendet: Mittwoch, 5. November 2003 14:34
An: Multiple recipients of list ORACLE-L
Betreff: Re: How do you genrate primary keys?
At one site I worked at, the programmers insisted on using Java milliseconds as the primary key -- so that they wouldn't have to hit the database twice (once to get the sequence number, once to insert the row). They swore up, down and six ways from Sunday that there could never, ever, EVER be a collision.
After we had collisions in development, we switched to sequences (one per table), with a trigger to populate the field on insert so that they wouldn't have to make the second round-trip.
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Rachel Carmichael INET: wisernet100_at_yahoo.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Stefan Jahnke INET: Stefan.Jahnke_at_bov.de Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Igor Neyman INET: ineyman_at_perceptron.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Mon Nov 10 2003 - 10:24:25 CST
![]() |
![]() |