2012-01-25 39 views
0

我有一個需要連接到POSTGRESQL 9.0服務器的SQL Server 2008。從SQL Server到postgresql的DBLink:get sequence nextval

一個我需要的任務是在PostgreSQL的

例1獲得一個序列的下一個值:

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

錯誤:

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

例2:

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

錯誤:

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".*

任何選項都沒有工作!

有沒有什麼好的選擇?

預先感謝您

+0

究竟做 「無工程」 呢?你有錯誤嗎?如果是,從哪個DBMS? –

+0

我對帖子進行了更新。我在SQLSERVER中出現錯誤。 TIA – galacha

+0

您是否可以使用該連接進行其他查詢?這只是你遇到問題的序列嗎? – Gary

回答

1

處理ODBC數據源和Postgres我必須這樣做:

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

我試過了,但沒有成功! – galacha

0

也許你的PostgreSQL連接是隻讀的,你試圖執行更新/插入請求?

NEXTVAL更新序列,嘗試:

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