Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: A simple question, I hope

Re: A simple question, I hope

From: Jim Lyons <jlyons_at_weblyons.com>
Date: 10 Jun 2001 10:36:42 -0700
Message-ID: <e67857c9.0106100936.3467a427@posting.google.com>

"Darryl" <dfs_at_nospam.com> wrote in message news:<x9xU6.5632$c37.668921_at_newsread1.prod.itd.earthlink.net>...
> Thanks, Reidel, but I guess I didn't specify my question well enough. I
> already have a sequence, and I already have a trigger that puts the next
> sequence value into the row.
>
> The problem is, at the point I insert the row, I need to know the new ID. I
> need that value returned to the Java program that performed the insert. And
> it's a high-transaction, high-activity system, so I can't do this:
>
> 1) INSERT new record
> 2) SELECT MAX(ID) FROM TABLE
>
> because a new record may have been inserted by another transaction between 1
> and 2.
>

You can select <seq>.currval from dual. Also, if you have need to use the value in several places, you can select <seq>.nextval from dual into a variable. Then you can use it as often as you want as well as in your original inserert statement. Received on Sun Jun 10 2001 - 12:36:42 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US