Home » SQL & PL/SQL » SQL & PL/SQL » Trigger is failing
Trigger is failing [message #602] Sun, 24 February 2002 22:19 Go to next message
Christoffer
Messages: 2
Registered: February 2002
Junior Member
Hello. Im trying to create a table that auto updates
a ID.

This is my SQL code..

create table foo5 (SEQ number, DATA varchar2(20));
create sequence foo5_idx;
create or replace trigger foo5_seq_ins
before insert on foo5
for each row
begin
select foo5_idx.nextval into :new.seq from
dual
end;
INSERT INTO foo5 (DATA) VALUES ('TEST');

This is my output when i insert the SQL code:
oracl:bf> create table foo5 (SEQ number, DATA
varchar2(20));
Command processed.

oracl:bf> create sequence foo5_idx;
Command processed.

oracl:bf> create or replace trigger foo5_seq_ins
-> before insert on foo5
-> for each row
-> begin
-> select foo5_idx.nextval into
:new.seq from dual
-> end;
Command processed.

oracl:bf> INSERT INTO foo5 (DATA) VALUES ('TEST');
ORA-04098: trigger 'BF.FOO5_SEQ_INS' is invalid and
failed re-validation (DBD ERROR: OCIStmtExecute)
oracl:bf>

Anyone got a tip for me?
Re: Trigger is failing [message #607 is a reply to message #602] Mon, 25 February 2002 00:09 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
your trigger is invalid....

replace this line

select foo5_idx.nextval into
:new.seq from dual

there is no ";" after dual
Re: Trigger is failing [message #617 is a reply to message #602] Mon, 25 February 2002 01:20 Go to previous messageGo to next message
Christoffer
Messages: 2
Registered: February 2002
Junior Member
...then i get a error in the "end;"

oracl:bf> create or replace trigger foo15_seq_ins
-> before insert on foo15
-> for each row
-> begin
-> select foo15_idx.nextval into
:new.seq from dual;
Command processed.

oracl:bf> end;
ORA-00900: invalid SQL statement (DBD ERROR:
OCIStmtExecute)
Re: Trigger is failing [message #621 is a reply to message #602] Mon, 25 February 2002 01:47 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
ur code is fine except foo15 should be changed to foo5, according to ur previous post.

after executing trigger . type show errors in sql prompt to find out the errors
Previous Topic: Oracle Forms 6i Button Trigger
Next Topic: Oracle Forms 6i Button Trigger
Goto Forum:
  


Current Time: Mon Sep 27 08:02:26 CDT 2021