我想使用动态sql语句,仅当变量不为null且大于零时才执行.像这样:
<isNotNull prepend="AND" property="ProprietaryId">
<isGreaterThan prepend="AND" property="ProprietaryId" compareValue="0">
G.PROPRIETARY_ID = #ProprietaryId#
</isGreaterThan>
</isNotNull>
Run Code Online (Sandbox Code Playgroud)
但没有预先加两个'AND'.
我已经阅读了文档,但没有找到好的例子.
要解决这个问题,我几乎从不使用"prepend"功能,而是写一个这样的sql:
WHERE 1=1
<isNotNull property="ProprietaryId">
<isGreaterThan property="ProprietaryId" compareValue="0">
AND G.PROPRIETARY_ID = #ProprietaryId#
</isGreaterThan>
</isNotNull>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12995 次 |
| 最近记录: |