Re: New to Oracle 7/triggers

From: Vijaya Kumar Nair <vnair_at_ccm.tdsnet.com>
Date: 1996/01/09
Message-ID: <30F316DE.3131_at_ccm.tdsnet.com>#1/1


L Orcutt wrote:
>
> I am using a before insert row trigger to update the primary key column
> of a table to be equal to a sequence.nextval as follows:
>
> CREATE OR REPLACE TRIGGER equipment_before_insert
> BEFORE INSERT ON equipment
> FOR EACH ROW
> BEGIN
> :new.equipment_id := equipment_seq.nextval;
> END;
>
> When I do this I get the error:
>
> PLS-00357: Table,View Or Sequence reference 'EQUIPMENT_SEQ' not allowed in this
> context.
>
> I would think that this would be a common thing to do. Can anybody tell me what
> I'm doing wrong or how this is normally accomplished?
>
> Thanks in advance for any help.
>
> Larry OrcuttYou cannot directly give that. Try

   select equipment_seq.next_val into :new.equipment_id from dual;

Hope this will help.

Vijay Nair Received on Tue Jan 09 1996 - 00:00:00 CET

Original text of this message