Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> RE: sequences

RE: sequences

From: Glenn Travis <>
Date: Wed, 12 Jul 2000 15:31:42 -0400
Message-Id: <>

What about the INSERT INTO (sequence.nextval, ...) RETURNING <colname> statement, rather than select (sequence) / insert?

> -----Original Message-----
> From: []On Behalf Of Regina
> Harter
> Sent: Wednesday, July 12, 2000 3:18 PM
> To: Multiple recipients of list ORACLE-L
> Subject: Re: sequences
> We have had problems in the past using triggers, usually related to the
> fact that the sequence value is a primary key. Since we insert usually
> through an application, if we don't need a reference to it at the
> time, it
> just goes into the insert statement as sequence_key.nextval, if
> the program
> needs a reference to the new row, we retrieve the sequence value into a
> variable and then include the variable in the insert command.
> At 09:23 AM 7/12/00 -0800, you wrote:
> >I wanted to ask how people are handling the insertion of unique keys in
> >Oracle. Please understand that my experience with generating
> unique keys
> >comes from an Informix background, wherein you can have a column with
> >datatype of 'serial'. This is an integer column which gets generated at
> >insert time with the next value automatically. You can then check the
> >sqlca area (return buffer) for the inserted value.
> >
> >I know in Oracle you can accomplish this with the SEQUENCE function. As
> >this is not automatically inserted by Oracle, how is the unqiue
> key value
> >inserted? Do most people use a before trigger, stored procs, or
> call the
> >sequence themselves? If using a client program (c, java), how is the
> >value for the unique key returned to the program which performed
> the insert?
> >
> >Examples, methods, design recommendations welcome...
> >
> --
> Author: Regina Harter
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: (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 Wed Jul 12 2000 - 14:31:42 CDT

Original text of this message