我正在尝试创建seuqunce触发器,但是当我在sql Developer中执行触发器创建sql时发生错误.我不明白,其实一切都很好.我在下面分享详情,请帮帮我,谢谢.
我的触发器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; /
和错误描述:
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
尝试以下方式:
原文链接:https://www.f2er.com/oracle/205643.htmlCREATE 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; /
你的序列应该是这样的
CREATE OR REPLACE SEQUENCE ACCOUNT_SEQ START WITH 1 INCREMENT BY 1;
希望能帮助到你.