Hi all,
I just created a testtable and a sequence to use as a primary key column value for that table.
I tried to create a BEFORE INSERT trigger on that table and in the trigger i tried to set up the primary key column value using the sequence
but while compiling i am getting the error "Error(9,30): PLS-00357: Table,View Or Sequence reference 'SEQ_OF_TESTTABLE.NEXTVAL' not allowed in this context"
My Version:Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
All the objects created with the same user. I would appraciate any help, thanks all
EDIT
I solved the problem using the below
create or replace
TRIGGER Bef_Ins_On_Testtable
BEFORE INSERT ON TestTable
FOR EACH ROW
declare
ntemp_id INT;
BEGIN
SELECT SEQ_OF_TESTTABLE.NEXTVAL INTO ntemp_id FROM DUAL ;
DBMS_OUTPUT.PUT_LINE('İNSERTED');
:NEW.VSURNAME := 'HAKKİ' ;
:NEW.NID := ntemp_id;
END;
But i wonder why i can use the sequence(just as seqeunce_name.NEXTVAL) in INSERT statement and why cant in trigger?
Edited by: user9371286 on 31.Tem.2010 04:15
Edited by: user9371286 on 31.Tem.2010 04:21
Edited by: user9371286 on 31.Tem.2010 04:27