插入Informix链接服务器时出错

时间:2015-03-27 21:43:12

标签: sql-server solaris ssms informix linked-server

我正在研究SQL Server数据库和Informix数据库之间的集成。数据库在不同的服务器上运行。我使用Informix OLE DB provider创建了一个到Informix的链接服务器。我能够从Informix中检索数据没问题。但是,当我尝试在Informix中运行插入时,收到以下错误:

The operation could not be performed because OLE DB provider "Ifxoledbc" for linked server "INFORMIX2" was unable to begin a distributed transaction.

我已经验证我可以使用Informix Client SDK附带的ConnectTest应用程序从SQL Server计算机插入Informix数据库,因此我不认为这是权限/防火墙问题。

以下是我在存储过程中运行插入的方法:

SET NOCOUNT OFF;

DECLARE
@error_msg NVARCHAR(4000),
@error_severity INT,
@error_state INT,
@today datetime,
@set_no int

SET XACT_ABORT ON;

SET @today = CONVERT(VARCHAR(10), GETDATE(), 1)

BEGIN DISTRIBUTED TRANSACTION

BEGIN TRY 

--do stuff, including insert into Informix

COMMIT TRANSACTION

END TRY

BEGIN CATCH

SELECT
@error_msg = ERROR_MESSAGE(),
@error_severity = ERROR_SEVERITY(),
@error_state = ERROR_STATE()

-- Error has occured and transaction is uncommittable
IF (XACT_STATE()) = -1
BEGIN
    SET @error_msg = @error_msg + ' The transaction has been rolled back.'
    ROLLBACK TRANSACTION
END

-- Transaction is still committable
IF (XACT_STATE()) = 1
BEGIN
    SET @error_msg = @error_msg + ' The transaction was recoverable and was committed.'
    COMMIT TRANSACTION 
END

-- Report the error
RAISERROR (@error_msg, @error_severity, @error_state)

END CATCH

我根据this post配置了分布式事务处理协调器。我也尝试将通信级别设置为No Authentication Required,但收到了同样的错误。

enter image description here

是否需要在Informix服务器上配置某些内容?就像Solaris中的分布式事务处理协调器一样?

1 个答案:

答案 0 :(得分:0)

虽然它不是交易问题的解决方案,但我找到了最好的解决方法。在SSMS中,转到链接服务器>供应商。右键单击Ifxoledbc(Informix OLE DB提供程序),然后选择“属性”。选中下面的属性启用。

enter image description here

“允许进程”将允许您插入Informix。但是,您无法使用交易。您必须使用Try-Catch,然后使用一些老式方法来确保插入成功(即,计算目标表)。