考虑以下示例
select * from foo where time +'10 day' >current_timestamp
Run Code Online (Sandbox Code Playgroud)
我想让这个查询参数化为Java,我不知道如何设置10 day?!(字符串不起作用)
Cra*_*ger 14
您可以传递一个String参数并将其强制转换,例如
select * from foo where (time + CAST(? AS interval)) > current_timestamp
Run Code Online (Sandbox Code Playgroud)
或者传递一个int参数乘以一个固定的间隔,如果你总是处理不太复杂的间隔天,那就更好了.例如
select * from foo where (time + ? * INTERVAL '1' DAY) > current_timestamp
Run Code Online (Sandbox Code Playgroud)
带setInt参数.
select * from foo where time +'10 day'::interval >current_timestamp;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3137 次 |
| 最近记录: |