【发布时间】:2016-03-24 19:03:42
【问题描述】:
我在添加带有时区的时间戳(又名 timestampz)作为 BIRT 中用于查询 postgreSQL 的参数时遇到问题。
在 BIRT 中没有参数的情况下,以下工作正常:
WHERE start_date = '2016-02-02 03:26:30.000Z'
现在使用 BIRT 中的参数,我无法让 DateTime 的任何组合起作用:
WHERE start_date = ?
接下来我将失败的参数设置为 DateTime 数据类型和字符串数据类型:
在参数编辑器中,我还尝试了以下默认值表达式:
BirtDateTime.now()
和
new Date().toISOString().replace("T"," ")
我总是收到一个错误提示:
ERROR: operator does not exist: timestamp with time zone = character varying
Hint: No operator matches the given name and argument type(s).
You might need to add explicit type casts.
我什至尝试过这样的投射:
WHERE start_date = ?::timestampz
BIRT 只是告诉我不支持语法,这意味着它只是不支持参数。
另一方面,如何调试 BIRT 查询?我想看看 startDate 参数在添加到查询之前是什么。
与此同时,我将不得不采取“hacky”路线。 :(
WHERE extract(year from start_date) = ?
AND extract(month from start_date) = ?
AND extract(day from start_date) = ?
----- 编辑 ----- 当! 8个月后,没有任何反应。这个还没有想通。直到今天一直在使用hacky路线。我猜只是没有足够的人使用 BIRT 和 Postgres :(
【问题讨论】:
-
你试试 start_date::TIMESTAMP = '2016-03-24 22:54:03'
-
刚试过,什么也没做。 BIRT 甚至无法识别参数。
标签: postgresql parameters birt timestamp-with-timezone