Home:ALL Converter>Generate sql statements with flyway placeholders

Generate sql statements with flyway placeholders

Ask Time:2020-08-24T22:14:16         Author:Krzysztof Drozd

Json Formatter

I trying to save some sql insert statements to files to use them for testing. I would like to use flyway placeholders for that but I'm not able to find any.

Some example in Java:

var sqlTXT = sql.insertInto(table("TBLNAME"))
     .set(field("strCol"), field("strVal").toString())
     .set(field("placeHolderCol"), field(inline("${flyway:user}")))
     .getSQL(ParamType.INLINED);

This will produce SQL string like this one:

insert into TBLNAME (strCol, placeHolderCol) values ('strVal', '${flyway:user}')

and I'm looking for something like this

insert into TBLNAME (strCol, placeHolderCol) values ('strVal', ${flyway:user})

So flyway can substitute ${flyway:user} and insert user name.

Is there any way to render sql like this or will I have to do it "manually"?

Author:Krzysztof Drozd,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/63562814/generate-sql-statements-with-flyway-placeholders
yy