Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Trigger with sequence
Hi,
I need to figure out how to do this. I have created this
table name : myclass
table column : id , name, type
primary key : id
sequence: myclassseq
I can use the sequence with insert statement , for example :
insert into myclass (id, name, type)
values (myclassseq.nextval, 'BT COM', 1)
I try to use trigger to insert the seq automatically, so that i can simply issue this :
insert into myclass (name, type)
values ('BT COM', 1)
And my insert statement will still work becoz the trigger will automatically insert a unique id.
I created a trigger myclasstr with the body below
BEGIN IF INSERTING THEN insert into myclass (id) values (myclass.nextval); END IF; END; WHen i try to insert into my table it will generate error. Pls let me know what has gone wrong ?
Your help is very much appreciated
Thank You
JK
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html
-- http://www.freelists.org/webpage/oracle-lReceived on Wed May 18 2005 - 00:08:43 CDT
![]() |
![]() |