tags:

views:

25

answers:

1

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?

+5  A: 

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 ,
...
Tony Andrews
Thanks, still learning PL/SQL most of my background is with MySQL and MS SQL SERVER
Matt