I am trying to delete some rows from a table using JDBC template and Oracle. I could not figure out how to delete with like condition. How do we pass parameters inside like condition?
I tried the below:
this.jdbcTemplate.update("delete from logs l where l.message like '%" + ":studentId" + "%'" ,new MapSqlParameterSource("studentId", studentIds[i]));
This code is written inside a for loop which should apply the delete statement for the every studentId inside studentIds array. It does not throw an error, but it also does not work.
In the debug log it says: Executing prepared SQL statement [delete from logs l where l.message like '%:studentId%']
Where as for a successfully executed statement debug log says: Executing prepared SQL statement [update students m set m.student_deleted='Y' where m.student_id = ? ]
Here it puts "?" instead of my parameter. I think it must be something like this for the statement with the like condition also. But instead it puts %:studentId%
What is the correct way of doing this, thanks in advance.