Re: SEQUENCE in a TRIGGER
From: Jared Still <jared_at_valleynet.com>
Date: 1996/02/29
Message-ID: <4h4e9h$ms_at_alpine.valleynet.com>#1/1
END; Jared Still, Oracle DBA
RxNet, Division of Value Health
"All opinions are mine, not my employers" jared_at_valleynet.com Received on Thu Feb 29 1996 - 00:00:00 CET
Date: 1996/02/29
Message-ID: <4h4e9h$ms_at_alpine.valleynet.com>#1/1
nathalie_at_MAIL.ATCON.COM (Nathalie) wrote:
>I created a SEQUENCE:
>CREATE SEQUENCE NEXT_KEY_GEN INCREMENT BY 1 START BY 1;
>and then a TRIGGER for my table TRANSACTION:
>CREATE TRIGGER TRIG_NEXT_KEY_TRANSACTION
> BEFORE INSERT ON TRANSACTION
> FOR EACH ROW
>BEGIN
> :NEW.P_KEY := next_key_gen.nextval;
>END;
>and I get the error message "PLS-00357: Table, view or sequence
>reference 'NEXT_KEY_GEN' not allowed in this context"
>Nathalie
>nathalie_at_atcon.com
Create a variable, assign the sequence to the variable, then update your key with the variable.
CREATE TRIGGER TRIG_NEXT_KEY_TRANSACTION
BEFORE INSERT ON TRANSACTION FOR EACH ROW NewKey integer; BEGIN select next_key_gen.nextval into NewKey form dual; :NEW.P_KEY := NewKey;
END; Jared Still, Oracle DBA
RxNet, Division of Value Health
"All opinions are mine, not my employers" jared_at_valleynet.com Received on Thu Feb 29 1996 - 00:00:00 CET