Oracle Script problem - create trigger not terminating

蹲街弑〆低调 提交于 2019-12-10 20:21:09

问题


I am trying to make some changes to an oracle database and have a script put together to do so. The problem is when it gets to a point in the script where I am creating a trigger it seems like the Create Trigger block does not properly terminate, when I look at the trigger afterwards it contains all of the remaining code in the script.

This is what I have:

CREATE OR REPLACE TRIGGER user_publish_log_trg
  BEFORE INSERT ON USER_PUBLISH_LOG
  FOR EACH ROW
    BEGIN
    SELECT user_publish_log_seq.NEXTVAL INTO :NEW.Id FROM dual;
    END user_publish_log_trg;

CREATE TABLE USER_APPROVAL_LOG
(
    Id number(10) NOT NULL ,
    CommodityId number(10) NOT NULL,
    QuarterEndDate DATE NOT NULL,
    ActionId int NOT NULL ,
...

What am I doing wrong in ending the trigger?


回答1:


You need to terminate the PL/SQL by using a slash on a new line, like this:

CREATE OR REPLACE TRIGGER user_publish_log_trg
  BEFORE INSERT ON USER_PUBLISH_LOG
  FOR EACH ROW
    BEGIN
    SELECT user_publish_log_seq.NEXTVAL INTO :NEW.Id FROM dual;
    END user_publish_log_trg;
/

CREATE TABLE USER_APPROVAL_LOG
(
    Id number(10) NOT NULL ,
    CommodityId number(10) NOT NULL,
    QuarterEndDate DATE NOT NULL,
    ActionId int NOT NULL ,
...


来源:https://stackoverflow.com/questions/3752708/oracle-script-problem-create-trigger-not-terminating

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!