围绕参数转义单引号时出错

Error escaping single quote around parameter

我在尝试使用 jdbctemplate 和 postgresql 转义参数周围的单引号时遇到错误。这是我正在尝试的本机查询 运行:

Select table.date from table where date > current_timestamp - interval '7 day'

“7”是“?”所在的参数去了。

我尝试使用两个单引号,但仍然收到一条错误消息:列索引超出范围

我也试过用双问号??而不是 ?,但这也不起作用。

Select table.date from table where date > current_timestamp - interval '? day'

这就是我想要达到的目标。非常感谢您的建议。

已找到解决方案,在此发布以供未来的读者使用:

Select table.date from table where date > current_timestamp - CAST (? AS INTERVAL))