Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: A simple question, I hope
"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 insert statement.
Jim Lyons Received on Sun Jun 10 2001 - 12:37:51 CDT
![]() |
![]() |