Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Triggers/sequences or interface code
As Mr. Lewis pointed out, getting sequence.nextval in trigger will require
additional query from dual and will not give you the new value back, while using
INSERT (id,...) VALUES(sequence.nextval,...) RETURNING id INTO :host_var
will do the the same job in one pass and will additionally give you back
the new generated id where trigger will just silently generate it and application
will have to dig for it after insert (again, additional query). Result is one statement
instead of three (or two if generated id is not needed right away), and easier
maintenance.
-- Vladimir Zakharychev (bob@dpsp-yes.com) http://www.dpsp-yes.com Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications. All opinions are mine and do not necessarily go in line with those of my employer. "Daniel Morgan" <dmorgan_at_exesolutions.com> wrote in message news:3CC9AF33.80AEE7E9_at_exesolutions.com...Received on Sat Apr 27 2002 - 04:44:17 CDT
> "J. Harris" wrote:
>
> > For incrementing PK or unique ids what is the "recommended" method for
> > achieving the best result: using triggers on insert events or manually doing
> > it at the interface level (i.e., using vba with access, or using coldfusion,
> > etc).
> >
> > John Harris
> > University of Utah
>
> SEQUENCE with BEFORE INSERT ROW LEVEL trigger.
>
> Daniel Morgan
>