0

Good Day!

PostgreSQL using flyway not able to create variable but using PostgreSQL client or command line its working well.

Below code is working well in client application [like DBeaver]

@set TEST = 'testing by us';

but when I add sql in flyway file its give error

@set TEST = 'testing by us';


SQL State : 42601 Error Code : 0 Message : ERROR: syntax error at or near "@" Position: 1 Location : db/migration/pgsql/_env/V1__zopn_obsolete.sql (C:\workspace\zara-flyway\target\classes\db\migration\pgsql_env\V1__zopn_obsolete.sql) Line : 1 Statement : @set TEST = 'testing by us'

Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "@"

Minesh
  • 148
  • 1
  • 2
  • 17
  • `@set` isn't a valid [SQL command](http://www.postgresql.org/docs/current/static/sql-commands.html). If it works in DBeaver, then this is something that DBeaver provides –  Jun 21 '22 at 07:05
  • Actually any sql working perfect with DBeaver or command prompt its working with flyway .sql files. I check with both way 1)set TEST1 = 'testing by us'; 2)\set TEST1 'testing by us'; but its give error flyway – Minesh Jun 21 '22 at 07:11
  • 1
    `\set` is a [psql](https://www.postgresql.org/docs/current/static/app-psql.html) command that only works within `psql`. I don't use Flyway, but I don't think it uses the `psql` command line client to run the script. So the only valid SQL commands you can use in a migration script are those [documented in the manual](http://www.postgresql.org/docs/current/static/sql-commands.html) –  Jun 21 '22 at 07:17

0 Answers0