Forum Stats

  • 3,872,756 Users
  • 2,266,468 Discussions
  • 7,911,296 Comments

Discussions

Weird error using :new in trigger

752032
752032 Member Posts: 26
edited Feb 7, 2010 2:49PM in SQL & PL/SQL
Hi buddies:

I'm using 10g and I've created an after insert trigger:

CREATE OR REPLACE TRIGGER "TR_INSERT_PERSON" AFTER
INSERT ON "PERSON" FOR EACH ROW BEGIN
INSERT INTO CHANGETABLE (ROWGUID, OPERATION, DATEOPERATION, TABLEID) VALUES (:NEW.UUID, 2, SYSDATE, 'PERSON');
END;

When I apply, it shows me the error message: "Missing IN or OUT parameter at index:: 1"
I know the cause of the error is the ':NEW' parameter, because when I replace it with a value it works, but I'm on a trigger body, what's wrong?

Thanx a lot in advance.

Best Answer

  • Solomon Yakobson
    Solomon Yakobson Member Posts: 19,921 Red Diamond
    Answer ✓
    Try the following in SQL*Plus:
    CREATE OR REPLACE
      TRIGGER KIKO.TR_INSERT_PERSON
        AFTER INSERT
        ON KIKO.PERSON
        FOR EACH ROW
        BEGIN 
            INSERT
              INTO CHANGETABLE(
                               ROWGUID,
                               OPERATION,
                               DATEOPERATION,
                               TABLEID
                              )
              VALUES (
                      :NEW.UUID,
                      2,
                      SYSDATE,
                      'PERSON'
                     );
    END;
    /
    SHOW ERRORS TRIGGER KIKO.TR_INSERT_PERSON
    SY.
«1

Answers

This discussion has been closed.