Issue
Using Java Spring Batch, I am generating a file based off of a query sent to a Oracle database:
SELECT
REPLACE(CLIENT.FirstName, chr(13), ' ')
FROM client_table CLIENT;
This query works fine when I run it in Oracle SQL Developer when I spool the result, but doesn't work when I try to utilize it to generate a file in Java Spring batch. It throws the error:
Message=Encountered an error executing step preparePrimaryIpData in job extract-primary-ip-job
org.springframework.jdbc.BadSqlGrammarException: Attempt to process next row failed; bad SQL grammar [
SELECT
REPLACE(CLIENT.FirstName, chr(13), ' ')
FROM client_table CLIENT
]; nested exception is java.sql.SQLException: Invalid column name
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:237)
Why is this working fine in Oracle Sql Developer but not when I try to utilize it in Java Spring Batch?
Also, the alias is necessary, because my actual query has a lot more joins, I just wanted to simplify it as an example.
Solution
Try some thing like :
SELECT REPLACE(CLIENT.FirstName, chr(13), ' ') columnNameX FROM client_table CLIENT
Answered By - Fado