We use Flyway as a DB migration tool. Now we want to use it for executing some import statements on our database.
In the data are some stored procedures and commands that contain the ";" character.
So we wanted to change the delimiter in the sql script.
In IBM Data studio I achieved this by following sql code:
--#SET TERMINATOR @
insert into "CONTROL"."AP18_ADMIN_RIGHTS" ("REG_ID", "USERNAME") values(12,'testuser')@
--#SET TERMINATOR ;
But when I tried to execute this code using flyway I got the following error message:
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:3.0:migrate (default-cli) on project healthstat-database: org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException: Error executing statement at line 3: insert into "CONTROL"."AP18_ADMIN_RIGHTS" ("REG_ID", "USERNAME") values(6,'testuser')@
[ERROR] insert into "CONTROL"."AP18_ADMIN_RIGHTS" ("REG_ID", "USERNAME") values(9,'testuser')@
[ERROR] insert into "CONTROL"."AP18_ADMIN_RIGHTS" ("REG_ID", "USERNAME") values(10,'testuser')@
[ERROR]
[ERROR] --#SET TERMINATOR: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601,SQLERRMC=(6,'testuser')@
[ERROR] insert into;, "USERNAME") values;<space>, DRIVER=3.64.82
Is it possible to change the delimiter in the sql files?
There is no SQL statement that you can execute in DB2 to set the statement delimiter.
The syntax
--#SET TERMINATOR xis specific to the DB2 Command Line Processor, and Data Studio implemented it (presumably) for compatibility.It appears that Flyway would have to be modified to support different statement terminators with DB2.