Hi,
I am trying to create a table from DbFit with a table name containing a date a few days before the DbFit test is run.
I've tried to create the CREATE TABLE statement as follows:
!|Query|SELECT to_char(current_date - interval '3', 'YYYYMMDD') as mindate|
!|Query|SELECT format('CREATE TABLE processing.bkp_%s_testtable(col1 int)',_:mindate) as createstmt|
createstmt will contain the following
CREATE TABLE processing.bkp_20170615_testtable(col1 int)
I then try to execute the SQL contained within that variable
!|Execute|_:createstmt|
But get the following error
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
Position: 1
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:410)
at dbfit.fixture.StatementExecution.run(StatementExecution.java:24)
at dbfit.fixture.Execute.doRows(Execute.java:27)
at fit.Fixture.doTable(Fixture.java:156)
at fitlibrary.traverse.AlienTraverseHandler.doTable(AlienTraverseHandler.java:21)
at fitlibrary.traverse.workflow.DoTraverseInterpreter.interpretWholeTable(DoTraverseInterpreter.java:104)
at fitlibrary.traverse.workflow.DoTraverseInterpreter.interpretWholeTable(DoTraverseInterpreter.java:89)
at fitlibrary.DoFixture.interpretWholeTable(DoFixture.java:73)
at fitlibrary.suite.InFlowPageRunner.run(InFlowPageRunner.java:27)
at fitlibrary.DoFixture.interpretTables(DoFixture.java:42)
at dbfit.DatabaseTest.interpretTables(DatabaseTest.java:26)
at fit.Fixture.doTables(Fixture.java:81)
at fit.FitServer.process(FitServer.java:81)
at fit.FitServer.run(FitServer.java:56) at fit.FitServer.main(FitServer.java:41)
Can anyone advise how I can do this?
Thanks,
Eoin