Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: ORACLE and a Counter field or Identity????
> Try looking up sequence generators in manual as this would be a better
approach
> than using a trigger. Then you can do the insert like:
> insert into table_name (col1, col2, etc...)
> values (sequence_name.nextval,:var2,etc...)
Definitely use sequence objects to generate the next value for your numeric
primary key. Now, some people like to use triggers to provide this value,
and others will do it in the client code as the previous author
illustrated; and a few others will write a stored procedure to encapsulate
the actual INSERT statement with the sequence object reference. If you're
feeling slick, you can write a program to generate stored procedure code,
and save yourself a lot of work in the long run.
-djc
Received on Wed Nov 12 1997 - 00:00:00 CST
![]() |
![]() |