Sql server 插入Informix链接服务器时出错
我正在研究SQL Server数据库和Informix数据库之间的集成。数据库在不同的服务器上运行。我已经使用创建了一个到Informix的链接服务器。我能够从Informix中检索数据,没有问题。但是,当我尝试在Informix中运行insert时,我收到以下错误:Sql server 插入Informix链接服务器时出错,sql-server,solaris,ssms,informix,linked-server,Sql Server,Solaris,Ssms,Informix,Linked Server,我正在研究SQL Server数据库和Informix数据库之间的集成。数据库在不同的服务器上运行。我已经使用创建了一个到Informix的链接服务器。我能够从Informix中检索数据,没有问题。但是,当我尝试在Informix中运行insert时,我收到以下错误: The operation could not be performed because OLE DB provider "Ifxoledbc" for linked server "INFORMIX2" was unable t
The operation could not be performed because OLE DB provider "Ifxoledbc" for linked server "INFORMIX2" was unable to begin a distributed transaction.
我已经验证了我可以使用Informix客户端SDK附带的ConnectTest应用程序从SQL Server机器插入Informix数据库,因此我认为这不是权限/防火墙问题
以下是我在存储过程中运行insert的方式:
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
我已经根据配置了分布式事务协调器。我还尝试将通信级别设置为不需要身份验证,但收到了相同的错误
Informix服务器上是否需要配置一些东西?就像Solaris中的分布式事务协调器一样?虽然它不是事务问题的解决方案,但我找到了最好的解决方法。在SSMS中,转到链接服务器>提供程序。右键单击Ifxoledbc(Informix OLE DB提供程序)并选择属性。选中以下属性的启用 “允许inprocess”将允许您插入Informix。但是,您不能使用事务。您必须使用Try-Catch,然后使用一些老式方法来确保插入成功(即,对目标表进行计数)