Is there a way to delete a bunch of elements using “where… in” in SQL, like so:
HashSet<String> idStrings = ...;
SimpleJdbcTemplate template = getTemplate();
template.update("DELETE FROM records WHERE idstring IN (?)", idStrings);
I am trying to get some old code to work that uses this method, but whenever I try to run it the Oracle JDBC drivers throw an exception:
QL state [99999]; error code [17004]; Invalid column type; nested exception is java.sql.SQLException: Invalid column type
This is with ojdbc5 11.2.0.1.0 and spring-jdbc 3.0.3
It’s possible, but you need one placeholder (
?) per ID, and each ID must be bound separately.You could also use NamedParameterJdbcTemplate, which
Be careful not to put too many values in the set of IDs. Oracle limits them to 1000, for example.