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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Using a Sequence to provide a primary key

Re: Using a Sequence to provide a primary key

From: Daniel A. Morgan <damorgan_at_exesolutions.com>
Date: Wed, 23 Jan 2002 20:16:57 +0000
Message-ID: <3C4F1A39.CC5B7D10@exesolutions.com>


The simplest way is in your insert statement like this:

INSERT INTO xyz
VALUES
(mysequence.NEXTVAL, someotherfieldvalue, someotherfieldvalue);

If you don't need a trigger don't make something that will break.

Daniel Morgan

Bill Hutchison wrote:

> I have created a table which needs to have a sequence define the
> primary key. I believe I have the sequence right, but I think I need
> a trigger based before insert to generate the new number. I haven't
> been able to get it right, and I'm hoping someone can tell me the
> right way to use a sequence to cause an ID field to be automatically
> updated when the rest of the fields have been entered.
>
> Thanks!
>
> If you could reply here and to billh_at_gci.net I'd appreciate it!
>
> I have some DOS utilities I wrote which are still useful if you do
> command lines, which I'd be glad to send in appreciation...
Received on Wed Jan 23 2002 - 14:16:57 CST

Original text of this message

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