I have a simple UPDATE statement like so:
UPDATE TABLE.COLUMN SET STATE = 'ACTIVE' WHERE STATE = 'INACTIVE'
In SQL Developer this works all the time, even if there aren’t any records with ‘INACTIVE’ status. The update simply returns ‘0 affected rows’.
However, when executing the same query with jdbcTemplate.update(query)
or jdbcTemplate.execute(query)
, it only works if there are any records with ‘INACTIVE’ status at the time of execution. Otherwise, if there aren’t any ‘INACTIVE’ records, I get:
class org.springframework.jdbc.BadSqlGrammarException StatementCallback; bad SQL grammar [UPDATE TABLE.COLUMN SET STATE = 'ACTIVE' WHERE STATE = 'INACTIVE']; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
I want the query to execute regardless there are any records with ‘INACTIVE’ status, but I don’t know what I’m missing/what to do to achieve this.
Thank you in advance!