Search code examples
oracle-databaseflyway

Could I use plsql variable constant or variable with Flyway


I want to use some constant in my init.sql file flyway to replace some duplicated texts.

But flyway throws me with migration failed:

SQL State  : 42000
Error Code : 42000
Message    : Erreur de syntaxe dans linstruction SQL {0}
Syntax error in SQL statement {0}; SQL statement:


    DECLARE
       myname_test CONSTANT VARCHAR2(10) := 'SOME TEXT';
    BEGIN
       INSERT INTO MYTABLE(ID,NAME) VALUES (1,myname_test);
    END;

By the way, I use Oracle Database.

So I wonder if flyway can read and execute PLSQL.


Solution

  • For filling the database with test data exist more than one solution and you need not really PLSQL.

    Here a set of possible ways to do the job, I think it will exists some more: