Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> How do I have sequence automatically insert on record insertion
I have a table that I want a sequence automatically inserted as the key value
when a record is inserted into it.
I have the following table:
parent
create sequence FOO increment by 1 start with 100;
I can insert a record into the table with the sql statement and it will insert the next value from the sequence into the table:
insert into parent (PARENTID, FIRST, LAST, SEX) VALUES (FOO.NextVal, 'BILL','BAKER','M');
Is there a way I can create a trigger which will automatically insert the FOO value from the sequence when I perform the insert below?
insert into parent (FIRST, LAST, SEX) VALUES ('MARY','SMITHY','F');
brian
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Thu Apr 08 1999 - 13:05:23 CDT