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: Kevin Brand <kevin.brandx_at_tel.gte.com>
Date: Wed, 19 Dec 2001 11:20:41 -0600
Message-ID: <9vqi36$l4f$1@news.gte.com>

You need the FOR EACH ROW clause to access the :new and :old variables.

-Kevin

"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 - 11:20:41 CST

Original text of this message

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