1

I am trying to create a simple trigger with following code -

CREATE OR REPLACE TRIGGER trg_menu_id BEFORE INSERT ON "menu" FOR EACH ROW
BEGIN
 SELECT
    menu_id_seq.NEXTVAL INTO : NEW.MENU_ID
 FROM
    dual ;
END ;

But I am getting - [Err] ORA-24344: success with compilation error I don't understand what I am doing wrong.

3
  • pay attention to colon before NEW. There should not be any space there. Also, is your table really named "menu" in lowercase? Commented Jun 15, 2016 at 6:27
  • I have also tried by removing space after colon. But same result. Yes table name is in lowercase Commented Jun 15, 2016 at 6:30
  • please post the complete error output. run : Show errors after the trigger execution to get complete output Commented Jun 15, 2016 at 6:49

1 Answer 1

1

At last my problem is solved. Field name was in small letter so I have to use NEW."menu_id" instead of NEW.MENU_ID and now it works fine!!! My new code is-

CREATE OR REPLACE TRIGGER trg_menu_id BEFORE INSERT ON "menu" FOR EACH ROW
BEGIN
 SELECT
    menu_id_seq.NEXTVAL INTO :NEW."menu_id"
 FROM
    dual ;
END ;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.