Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Table trigger and NEW value
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
*
-- Hello FlexReceived on Wed Dec 19 2001 - 07:04:48 CST