当前位置: 动力学知识库 > 问答 > 编程问答 >

Liquibase - uploading many Oracle triggers in one file

问题描述:

I have a number of Oracle triggers stored in a file which we upload to our DB using sqlplus. We want to use liquibase instead to manage this, but I don't really want to split out the triggers into separate files. The file looks like:

 create or replace trigger Trig1 ...

...

end Trig1;

/

create or replace trigger Trig2 ...

...

end Trig2;

/

...etc.

I've tried

<sqlFile splitStatements="true" endDelimiter="/" path="triggers.sql">

but it still seems to be trying to split on ';'. If I change splitStatements to false. it then ignores the '/' and includes everything as an invalid single trigger.

Any ideas?

TIA.

网友答案:

I realize this is an old issue and OP has moved on, but for anyone else I ended up finding the answer here: http://forum.liquibase.org/topic/oracle-end-delimiter-issue.

It turns out "endDelimiter" is a regular expression -- this string should be used:

\n/\s*\n|\n/\s*$
网友答案:

I recently got this issue. endDelimiter should be:

endDelimiter="(?m)^/$"
网友答案:

I have a similar problem with Oracle 11g and Liquibase. I get an ORA-00911. In my db-changelog.xml I point to a sql file where I have triggers. This does not work at all. I have tested the things you said above with /\;

CREATE OR REPLACE TRIGGER ADRESSE_ID_TR 
            BEFORE INSERT ON ADRESSE 
            FOR EACH ROW 
            WHEN (new.ID IS NULL) BEGIN 
            SELECT adresse_seq.NEXTVAL 
            INTO   :new.ID 
            FROM   dual; 
            END ADRESSE_ID_TR;\

My workaround is adding a in in db-changelog.xml. I don't like it because the db-changelog.xml is going to be very large and I want it in the .sql files not in db-changelog.xml.

Another problem is when I generate DDL's with tools like Oracle SQL Developer and paste them in, they don't work. A lot of sql's don't work, probably not supported. I spend a lot of time testing my SQL's and Liquibase with Eclipse to fix the SQL's. Any tips or will you fix this?

网友答案:

That syntax looks correct. The endDelimiter should be telling it to override the default ; delimiter and use / instead. What version of liquibase are you using? Does it help if you put the \ not by itself?

  create or replace trigger Trig1 ...
  ...
  end Trig1; /

  create or replace trigger Trig2 ...
  ...
  end Trig2; /

  ...etc.
分享给朋友:
您可能感兴趣的文章:
随机阅读: