Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Using a Sequence to provide a primary key
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
![]() |
![]() |