代码:
<int-jdbc:inbound-channel-adapter
query="SELECT USER_ID,BOOK_ID FROM BOOK WHERE ROWNUM <= 11"
channel="index-back-data" data-source="dataSource"
max-rows-per-poll="10"
update=" ? "
row-mapper="DataRowMapper">
<int:poller fixed-delay="10000" />
</int-jdbc:inbound-channel-adapter>
问题:
在轮询BOOK表时,我可能会将bookid视为null,那么如何使用update属性删除它?
我们可以在更新中使用条件删除吗?
:bookId != null ? 'DELETE FROM BOOK WHERE USER_ID = :userId AND BOOK_ID = :bookId : DELETE FROM BOOK WHERE USER_ID = :userId AND BOOK_ID IS NULL
任何帮助将不胜感激!
答案 0 :(得分:1)
如果您允许在book表中使用null主键存在行,我认为您可能存在数据完整性问题。这有点编辑,那么:
update="DELETE FROM BOOK WHERE (USER_ID = :userId AND BOOK_ID = :bookId) OR (USER_ID = :userId AND BOOK_ID is null)"