在 Postgres 中,使用 Spring JDBC 的 NamedParameterJdbcTemplate,如果我想使用可能包含空值的 where 子句删除一行,我必须执行这样的操作......
val sql = if (someOtherValue == null) {
"delete from some_table where some_column = :someValue and some_other_column is null"
} else {
"delete from some_table where some_column = :someValue and some_other_column = :someOtherValue"
}
如果我想批量删除给定输入集合中的某些值someOtherValue
可能为空的记录,有没有办法在一条 SQL 语句中完成此操作?还是我必须将集合拆分成包含空值的记录someOtherValue
和不包含空值的记录?