Can anyone provide guidance or an example of using IBDAC components to perform a two-phase commit involving two Firebird databases?
Thanks,
Dennis
Two phase commit with IBDAC and Firebird
-
AndreyZ
Hello,
You can try using this code:
You can try using this code:
Code: Select all
IBCQuery1.AutoCommit := false;
IBCQuery1.Connection := IBCConnection1; // connection to the first database
IBCQuery1.UpdateTransaction := IBCTransaction; // one transaction for both databases
IBCQuery1.Open;
IBCQuery2.AutoCommit := false;
IBCQuery2.Connection := IBCConnection2; // connection to the second database
IBCQuery2.UpdateTransaction := IBCTransaction;
IBCQuery2.Open;
IBCTransaction.AddConnection(IBCConnection1);
IBCTransaction.AddConnection(IBCConnection2);
IBCTransaction.StartTransaction;
try
IBCQuery1.Edit;
IBCQuery1.FieldByName('test1').AsString := 'test1';
IBCQuery1.Post;
IBCQuery2.Edit;
IBCQuery2.FieldByName('test2').AsString := 'test2';
IBCQuery2.Post;
IBCTransaction.Commit;
except
IBCTransaction.Rollback;
end;