Search code examples
sqlderby

What is the correct way to include a variable inside an Apache derby Export_Query


I am trying to export data from a derby table to a file. I'm having issues with the WHERE clause. What I have is this.

s.execute("CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY('SELECT *FROM REPORT WHERE DATE = " + conversion.getDate() + " ' , 'C:\\Pos\\daily_report.csv' , ',' , null, null)");

This exception

Java.sql.SQLSyntaxErrorException: Syntax error: Encountered "Sep" at line 1, column 37.

was thrown while evaluating an expression.

Could someone direct me regarding this.


Solution

  • I found it.

    s.execute("CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY('SELECT*FROM REPORT WHERE DATE = ' ' " + conversion.getDate() + " ' ' ' , 'C:\Pos\daily_report.csv' , ' , ' , null, null)");