Home » SQL & PL/SQL » SQL & PL/SQL » problem with trigger.
problem with trigger. [message #216937] Tue, 30 January 2007 23:08 Go to next message
chinmay_uce02
Messages: 11
Registered: January 2007
Junior Member
hi all
i am creating a trigger to insert the employee number into a table using a sequence.the code for creating a trigger is

create trigger trigger1
before insert
on t
for each row
declare
begin
:new.NO:=seqq.nextval;
end
/

here
t-table with columns no and name.
seqq-sequence

when i execute the above code the error generate is

Warning: Trigger created with compilation errors.

when i execute the command
SQL> show errors trigger trigger1;

the out put is
Errors for TRIGGER TRIGGER1:

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/1 PL/SQL: Statement ignored
3/15 PLS-00357: Table,View Or Sequence reference 'SEQQ.NEXTVAL' not
allowed in this context

but the sequence is working properly as

SQL> select seqq.nextval from dual;

NEXTVAL
----------
2
any help

thanks in advance
chinmay

Re: problem with trigger. [message #216938 is a reply to message #216937] Tue, 30 January 2007 23:57 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Try
select seqq.nextval into :new.NO from dual;
instead of
:new.NO:=seqq.nextval;

OraFAQ
By
Vamsi

[Updated on: Wed, 31 January 2007 00:02]

Report message to a moderator

Re: problem with trigger. [message #216942 is a reply to message #216938] Wed, 31 January 2007 00:24 Go to previous message
chinmay_uce02
Messages: 11
Registered: January 2007
Junior Member
hi vamsi
great man...now its working.
thanks a lot.
Previous Topic: error in create sequence.
Next Topic: help for using update query
Goto Forum:
  


Current Time: Thu Dec 08 10:42:30 CST 2016

Total time taken to generate the page: 0.18288 seconds