Re: sequence.nextval out a trigger

From: SANJAY PURI <skp_at_ix.netcom.com>
Date: 7 Oct 1994 21:04:19 GMT
Message-ID: <374d4j$e2o_at_ixnews1.ix.netcom.com>


In <373ibl$p8r_at_aragorn.unibe.ch> acherman_at_asterixiam.unibe.ch (Franz Achermann) writes:

>
>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:
>Table,View Or Sequence reference 'KEY_GENERATOR' not allowed in this context
>
>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)
>

Hi Franz,

In assignments like what you are doing, the usage of nextval is not allowed. It must be used only within a SQL statement.

Vijaya Kumar Nair Received on Fri Oct 07 1994 - 22:04:19 CET

Original text of this message