我对这个问题做了更多的研究,答案如下:特性包中的 DB2OleDB 提供程序不支持事务,但 HIS(主机集成服务)支持。此外,您必须在调用 BEGIN DISTRIBUTED TRANS 之前使用 DISTRIBUTED TRANSACTIONS 并将 XACT_ABORT 设置为 ON。
一个例子:
SET XACT_ABORT ON
go
BEGIN DISTRIBUTED TRAN
Go
INSERT INTO OPENQUERY (SYS1_DUW,
'SELECT * from STROBAEK.DUWTEST')
(AREAID, AREADESC,REGIONID)
values ('11111', 'Redmond', 101)
ROLLBACK TRAN
Go
exec ('SELECT * FROM STROBAEK.DUWTEST') at SYS1_DUW
Go
AREAID AREADESC REGIONID
00001 BadBoy 104
00002 BadGirl 105
BEGIN DISTRIBUTED TRAN
Go
INSERT INTO OPENQUERY (SYS1_DUW,
'SELECT * from STROBAEK.DUWTEST')
(AREAID, AREADESC,REGIONID)
values ('11111', 'Bellevue', 101)
COMMIT TRAN
Go
exec ('SELECT * FROM STROBAEK.DUWTEST') at SYS1_DUW
Go
AREAID AREADESC REGIONID
00001 BadBoy 104
00002 BadGirl 105
11111 Bellevue 101
BEGIN DISTRIBUTED TRAN
Go
UPDATE OPENQUERY (SYS1_DUW,
'SELECT * from STROBAEK.DUWTEST')
set AREADESC = 'Copenhagen' where REGIONID = 101
COMMIT TRAN
Go
SET XACT_ABORT OFF
exec ('SELECT * FROM STROBAEK.DUWTEST') at SYS1_DUW
AREAID AREADESC REGIONID
00001 BadBoy 104
00002 BadGirl 105
11111 Copenhagen 101
一个问题:DTC 和 Mirror 不能一起工作