All Apps and Add-ons

DB connect postgres database SQL statement Unix timestamp filtering execution failed

Steven01
New Member

嗨,兄弟,

我遇到了一个关于 postgres 数据集成的令人困惑的问题。
我想每两分钟执行一次此语句,以便从数据库中获取最新结果,因此我使用以下语句进行筛选。

SELECT history_uint.itemid,history_uint.value,interface.ip,items.name,hosts.host,TO_TIMESTAMP




(history_uint.clock) AS clock_datetime
FROM history_uint
JOIN items
ON history_uint.itemid = items.itemid
JOIN hosts
ON items.hostid = hosts.hostid
JOIN interface
ON interface.hostid = hosts.hostid
WHERE history_uint.clock > (FLOOR(EXTRACT(EPOCH
FROM NOW())) - 120)
AND items.flags = 4
AND (items.name LIKE '%Bits sent%'
OR items.name LIKE '%Bits received%')
AND (hosts.host LIKE 'CN%'
OR hosts.host LIKE 'os%')
ORDER BY history_uint.clock DESC LIMIT 90000;

此 SQL 语句在数据库工具中完美执行

Steven01_1-1730361327860.png

但是,此 SQL 语句无法在 dbxquery 中执行,错误未知

Steven01_2-1730361418309.png

我发现关键原因是以下 SQL 语句:

其中 history_uint.clock > (FLOOR(EXTRACT(EPOCH
FROM NOW())) - 120)

当我用 Unix 时间戳替换 1 时,一切都很好

Steven01_3-1730361629964.png

我尝试用其他 SQL 语句替换它,但它们都失败了。
请帮我一起分析这个问题。谢谢。

添加一些环境信息:
Postgres 版本:14.9

java 版本 21.0.5
DB connet 版本 3.18.1

postgres JDBC 版本 1.2.1
谢谢

 

 

Labels (1)
0 Karma
Get Updates on the Splunk Community!

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...

State of Splunk Careers 2024: Maximizing Career Outcomes and the Continued Value of ...

For the past four years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...

Data-Driven Success: Splunk & Financial Services

Splunk streamlines the process of extracting insights from large volumes of data. In this fast-paced world, ...