Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Script problem - create trigger not terminating

Tags:

sql

ddl

oracle10g

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?

like image 870
Matt Avatar asked Jan 24 '26 13:01

Matt


1 Answers

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 ,
...
like image 166
Tony Andrews Avatar answered Jan 27 '26 01:01

Tony Andrews



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!