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: trigger syntax for after insert

Re: trigger syntax for after insert

From: Rob van Wijk <rwijk72_at_gmail.com>
Date: Mon, 02 Jul 2007 08:25:33 -0000
Message-ID: <1183364733.271148.131090@n2g2000hse.googlegroups.com>


It is an ORA-04082 and the reason is reported quite clearly in the error message itself:

SQL> CREATE OR REPLACE TRIGGER AFT_IN_TEAMS   2 AFTER INSERT ON EMP
  3
  4 BEGIN
  5 IF :NEW.Deptno = 1 THEN

  6          INSERT INTO DEPT (DEPTNO,DNAME) VALUES (
  7                  :NEW.Deptno,
  8                  'Dept ' || :NEW.Deptno)
  9          ;

 10 END IF;
 11 END;
 12 /
CREATE OR REPLACE TRIGGER AFT_IN_TEAMS
                          *

FOUT in regel 1:
.ORA-04082: NEW or OLD references not allowed in table level triggers

So make it a row level trigger, as probably intended:

SQL> CREATE OR REPLACE TRIGGER AFT_IN_TEAMS   2 AFTER INSERT ON EMP
  3 FOR EACH ROW
  4 BEGIN
  5 IF :NEW.Deptno = 1 THEN

  6          INSERT INTO DEPT (DEPTNO,DNAME) VALUES (
  7                  :NEW.Deptno,
  8                  'Dept ' || :NEW.Deptno)
  9          ;

 10 END IF;
 11 END;
 12 /

Trigger is aangemaakt.

Regards,
Rob. Received on Mon Jul 02 2007 - 03:25:33 CDT

Original text of this message

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