0

代码 :

<int-jdbc:inbound-channel-adapter
        query="SELECT USER_ID,BOOK_ID FROM BOOK WHERE ROWNUM &lt;= 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

任何帮助将不胜感激 !

4

1 回答 1

1

我认为如果您允许在 book 表中存在主键为空的行,您可能会遇到数据完整性问题。这有点社论,那么:

update="DELETE FROM BOOK WHERE (USER_ID = :userId AND BOOK_ID = :bookId) OR (USER_ID = :userId AND BOOK_ID is null)"
于 2013-01-24T22:19:57.127 回答