考虑以下示例
select * from foo where time +'10 day' >current_timestamp
我想让这个查询参数化为Java,但我不知道如何设置10 day
?! (字符串不起作用)
您可以传递一个 String 参数并对其进行强制转换,例如
select * from foo where (time + CAST(? AS interval)) > current_timestamp
或者传递一个 int 参数乘以固定间隔,如果您始终使用天而不是更复杂的间隔,则更好。例如。
select * from foo where (time + ? * INTERVAL '1' DAY) > current_timestamp
with a setInt
范围。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)