从 SQL Server 到 postgresql 的 DBLink:获取序列 nextval

发布于 2024-12-28 20:05:46 字数 732 浏览 6 评论 0原文

我有一个 SQL Server 2008,需要连接到 POSTGRESQL 9.0 服务器。

我需要的任务之一是通过 POSTGRESQL

示例 1:

execute ('select nextval( ''cadastro.pessoa_seq'' )' ) at POSTGRESQL ;

错误获取序列的下一个值:

消息 7215,级别 17,状态 1,第 1 行无法执行语句 远程服务器“POSTGRESQL”。*

示例 2:

select * from openquery( POSTGRESQL ,'select nextval( ''cadastro.pessoa_seq'' )')

错误:

消息 7399,级别 16,状态 1,第 1 行 OLE DB 提供程序“MSDASQL” 链接服务器“POSTGRESQL”报告错误。该提供商报告了 意外的灾难性失败。消息 7350,16 级,状态 2,第 1 行 无法从 OLE DB 提供程序“MSDASQL”获取列信息 链接服务器“POSTGRESQL”。*

这些选项都不起作用!

有什么好的替代方案吗?

先感谢您

I've got a SQL Server 2008 that needs to connect to a POSTGRESQL 9.0 server.

One of the tasks that i need is to get the next value of a sequence over the POSTGRESQL

Example 1 :

execute ('select nextval( ''cadastro.pessoa_seq'' )' ) at POSTGRESQL ;

error:

Msg 7215, Level 17, State 1, Line 1 Could not execute statement on
remote server 'POSTGRESQL'.*

Example 2 :

select * from openquery( POSTGRESQL ,'select nextval( ''cadastro.pessoa_seq'' )')

error:

Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "MSDASQL" for
linked server "POSTGRESQL" reported an error. The provider reported an
unexpected catastrophic failure. Msg 7350, Level 16, State 2, Line 1
Cannot get the column information from OLE DB provider "MSDASQL" for
linked server "POSTGRESQL".*

None of these options works!

Is there any good alternative ?

Thank you in advance

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

っ左 2025-01-04 20:05:46

处理 ODBC 源和 postgres 我必须这样做:

nextval(''cadastro.pessoa_seq''::regclass) for it to work 

dealing with ODBC sources and postgres I have to do this:

nextval(''cadastro.pessoa_seq''::regclass) for it to work 
如此安好 2025-01-04 20:05:46

也许您的 Postgresql 连接是只读的,您是否尝试执行更新/插入请求?

nextval 更新序列,尝试:

currval(''cadastro.pessoa_seq''::regclass)

Perhaps your Postgresql connection is readonly , have you tried to execute an update/insert request ?

nextval update the sequence , try:

currval(''cadastro.pessoa_seq''::regclass)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文