我试过这个:
from Table where (:par1 is null or col1 = :par1)
Run Code Online (Sandbox Code Playgroud)
但它发生了
from Table where :par1 is null
Run Code Online (Sandbox Code Playgroud)
始终返回表的所有行,即使:par1不为null.
而
select * from table where col1 = 'asdf'
Run Code Online (Sandbox Code Playgroud)
不会返回任何行.
我不能使用本机语法,因为我的应用程序应该在不同的数据库引擎上运行
Il-*_*ima 62
nvl与HQL中的coalesce命令等效的是命令. 如果不为null coalesce(a,b)则返回,否则返回.aab
所以你会想要的东西:
from Table where col1 = coalesce(:par1, 'asdf')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
48221 次 |
| 最近记录: |