通过dblink插入远程数据库

发布于 2025-02-08 20:49:23 字数 804 浏览 1 评论 0原文

我正在尝试通过此查询插入远程数据库

当我仅选择这些列时,查询正常工作,但是当我尝试使用30插入时 - 日间隔条件表明语法中的错误 我不知道我在选择30天的数据的间隔语法中做错了什么。 谁能帮我这个! 谢谢

INSERT INTO tc_new_events
SELECT * FROM dblink ('dev_connec','SELECT id,type,eventtime,
deviceid,positionid,geofenceid,
attributes,maintenanceid FROM tc_events
WHERE eventTime < (NOW() - '30 days' INTERVAL  )') 
AS DATA (id int ,type varchar , eventtime timestamp without time zone , 
deviceid integer,positionid integer,geofenceid integer ,
attributes varchar,maintenanceid integer);
ERROR:  syntax error at or near "30"
LINE 13: ...anceid FROM tc_events WHERE eventTime < (NOW() - '30 days' I...
                                                              ^
SQL state: 42601
Character: 994

I'm trying to insert into remote DB via this query

The query works fine When I only select these columns but when I'm trying to insert with a 30-day interval condition it shows that an error in syntax
I don't know What I'm doing wrong in the interval syntax for selecting data of 30 days.
Can anyone help me with this!
Thanks

INSERT INTO tc_new_events
SELECT * FROM dblink ('dev_connec','SELECT id,type,eventtime,
deviceid,positionid,geofenceid,
attributes,maintenanceid FROM tc_events
WHERE eventTime < (NOW() - '30 days' INTERVAL  )') 
AS DATA (id int ,type varchar , eventtime timestamp without time zone , 
deviceid integer,positionid integer,geofenceid integer ,
attributes varchar,maintenanceid integer);
ERROR:  syntax error at or near "30"
LINE 13: ...anceid FROM tc_events WHERE eventTime < (NOW() - '30 days' I...
                                                              ^
SQL state: 42601
Character: 994

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文