Brandon Wagner
Brandon Wagner

Reputation: 893

Grails Migrations Plugin Creating Triggers

I have an SQL file with DML Trigger creations that I run as an SQL script. However, I'd like to include that in my Grails database migrations changelog. I run all of my other SQL scripts using the changelog (with the sqlFile tag). When I do this same process with my triggers sql file I get all sorts of invalid sql statement errors (invalid sql statement on "end;").

Is is having a problem because of the PL/SQL nature of triggers? If so, how can I get around this?

This is the type of statements I'm trying to run:

   CREATE OR REPLACE TRIGGER "A_HST"
     BEFORE
       delete or update
         on TableA
     for each row
       begin
          insert into A_history
            ( ID,
            VERSION,
            COMMENTS,
            description,
            NAME,
            UPDATEDBY_ID)
   values
     ( :old.id,
        :old.VERSION,
        :old.comments,
        :old.description,
        :old.name,
        :old.UPDATEDBY_ID);
    end; 

/

ALTER TRIGGER "A_HST" ENABLE;

Upvotes: 1

Views: 357

Answers (1)

Svetozar Misljencevic
Svetozar Misljencevic

Reputation: 736

Maybe you are having an issue with delimiters? Take a look at endDelimiter attribute in http://www.liquibase.org/documentation/changes/sql_file.html

You could set the endDelimiter to ';;' and make sure that the CREATE TRIGGER statements are followed by ';;'

Upvotes: 1

Related Questions