I'm trying create seuqunce trigger but error occurs when I executing the trigger create sql in SQL Developer. I don't understand, actually everything looks fine. I share the details below, please help me, thanks.
My trigger sql:
CREATE OR REPLACE TRIGGER "TRIGGER1" BEFORE INSERT ON ACCOUNTS
FOR EACH ROW
WHEN (new."ID" IS NULL)
BEGIN
SELECT ACCOUNTS_SEQ.NEXTVAL
INTO :new."ID"
FROM dual;
END;
/
And error description:
Error starting at line : 5 in command -
CREATE OR REPLACE TRIGGER "TRIGGER1" BEFORE INSERT ON ACCOUNTS
FOR EACH ROW
WHEN (new."ID" IS NULL)
BEGIN
SELECT ACCOUNTS_SEQ.NEXTVAL
INTO :new."ID"
FROM dual
Error report -
SQL Command: trıgger "TRIGGER1"
Failed: Warning: completed with warning
Error starting at line : 12 in command -
END
Error report -
Unknown Command
Try it following way:
Your Sequence should look like this
Hope it helps.