Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2013
    Posts
    46

    Unanswered: Unable to compile trigger

    CREATE OR REPLACE TRIGGER abc.abcd
    AFTER INSERT OR DELETE
    ON abc.abcd
    REFERENCING
    NEW AS NEW
    FOR EACH ROW
    BEGIN

    IF INSERTING THEN
    INSERT INTO abc.abcd(abc) VALUES (NEW.abc)

    ELSEIF DELETING THEN
    DELETE FROM abc.abcd WHERE abc=NEW.abc;

    END IF;

    END;

    getting the following error:
    sql command not ended properly.

    What may be the issue?

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Code:
    CREATE OR replace TRIGGER abc.abcd 
      AFTER INSERT OR DELETE ON abc.abcd 
      REFERENCING NEW AS NEW 
      FOR EACH ROW 
    BEGIN 
        IF inserting THEN 
          INSERT INTO abc.abcd 
                      (abc) 
          VALUES      (:NEW.abc); 
        ELSIF deleting THEN 
          DELETE FROM abc.abcd 
          WHERE  abc = :NEW.abc; 
        END IF; 
    END;
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Sep 2013
    Posts
    46
    now it is saying:

    Error(6,8): PLS-00103: Encountered the symbol "DELETING" when expecting one of the following: := . ( @ % ;

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Quote Originally Posted by jigmod01 View Post
    now it is saying:

    Error(6,8): PLS-00103: Encountered the symbol "DELETING" when expecting one of the following: := . ( @ % ;

    error is due to a typographical error on that line
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Sep 2013
    Posts
    46
    THANK YOU. it was a simple error of spaces before and after =

  6. #6
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    don't this have a mutating error since the insert and delete table are the same table that the trigger is on.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •