sequence.nextval out a trigger
Date: 7 Oct 1994 13:27:17 GMT
Message-ID: <373ibl$p8r_at_aragorn.unibe.ch>
Hi,
I'd like to have a before insert for each row trigger, which inserts automatically keys. But what am I doing wrong in the following example:
CREATE TABLE Personal (
Per_Nr number(6) PRIMARY KEY,
Per_Name varchar(20) not null
);
CREATE SEQUENCE key_generator;
CREATE TRIGGER insert_personal
BEFORE INSERT ON Personal
FOR EACH ROW
DECLARE v number(6);
BEGIN
:new.Per_Nr := key_generator.nextval;
END;
/
The sqlplus interpreter simply says:
What am I missing or is it really not possible to use sequences
out a triggerbody. May I really ask all the users to type:
INSERT INTO Personal VALUES(key_generator.nextval, 'text');
Any Hints are welcome
Franz Achermann (acherman_at_iwi.unibe.ch)
Received on Fri Oct 07 1994 - 14:27:17 CET
Table,View Or Sequence reference 'KEY_GENERATOR' not allowed in this context