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

Home -> Community -> Mailing Lists -> Oracle-L -> Trigger with sequence

Trigger with sequence

From: Kean Jacinta <jacintakean_at_yahoo.com>
Date: Tue, 17 May 2005 21:04:03 -0700 (PDT)
Message-ID: <20050518040404.10605.qmail@web52904.mail.yahoo.com>


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-l
Received on Wed May 18 2005 - 00:08:43 CDT

Original text of this message

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