Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Table trigger and NEW value

Re: Table trigger and NEW value

From: Stephen B <stephen.bell_at_cgi.ca>
Date: Wed, 19 Dec 2001 11:47:44 -0500
Message-ID: <ay3U7.22744$x25.2400640@news20.bellglobal.com>


Hi,

I believe it's because your trigger is a BEFORE trigger...the "new" value doesn't exist yet?

"Flex" <flexNOSP_at_Mfreemail.it> wrote in message news:Qf0U7.18137$o9.668942_at_news1.tin.it...
> Why I cannot use the variable NEW in this kind of trigger
>
> CODE TRIGGER
>
> CREATE or REPLACE TRIGGER t_nstudents
> BEFORE
> INSERT OR UPDATE OF ID_Cycle ON Students
>
> declare
> actual_s NUMBER ;
> available_places NUMBER ;
> begin
> SELECT COUNT(*) INTO actual_s
> FROM students
> WHERE ID_Cycle = :new.ID_Cycle ;
>
> SELECT availableplaces INTO available_places
> FROM cycles
> WHERE cyclenumber = :new.ID_Cycle;
>
> IF actual_s < available_places THEN
> RAISE_APPLICATION.ERROR(-2061,'Cannot insert student into this cycle
> ,please check available places & Student');
> END IF ;
> end;
> /
>
>
> ERRORE SQLPLUS
> SQL> @trigger
> Input trunc on character 1
> Immettere un valore per student: 17
> vecchio 17: RAISE_APPLICATION.ERROR(-2061,'Cannot insert student into
> this cycle ,please check available places & Student');
> nuovo 17: RAISE_APPLICATION.ERROR(-2061,'Cannot insert student into
> this cycle ,please check available places 17');
> CREATE or REPLACE TRIGGER t_nstudents
> *
> ERROR row 1:
> ORA-04082: reference NEW or OLD
> SQL>
>
>
> --
> Hello
> Flex
>
>
Received on Wed Dec 19 2001 - 10:47:44 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US