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: Darryl <dfs_at_nospam.com>
Date: Sat, 09 Jun 2001 22:10:37 GMT
Message-ID: <x9xU6.5632$c37.668921@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.

I've messed around with a PL/SQL function or procedure, but I was hoping someone had done something like this already.

Thanks,
Darryl

"Reidel Jogie" <reidel_at_usa.net> wrote in message news:iIgU6.64451$G5.14064108_at_news1.rdc1.md.home.com...
> Have a look a SEQUENCES. You can select the next value of a sequence into
> the ID field in a BEFORE INSERT ROW trigger.
>
> In article <vO%T6.1896$c37.193703_at_newsread1.prod.itd.earthlink.net>,
> "Darryl" <dfs_at_nospam.com> wrote:
>
> > How do I get the trigger-generated ID number for the row I just added to
> > a table? I can't do a SELECT MAX(ID) because it's a high transaction
> > system.
> >
> > Thanks,
> > Darryl
> >
> >
>
Received on Sat Jun 09 2001 - 17:10:37 CDT

Original text of this message

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