How to create a two phase commit with Delphi and InterBase
This week i was given a 2h webinar over Understanding Transactions with InterBase and Delphi ( a playback you can find here LINK ).
One open Question was how to create a two phase commit with IBX in Delphi.
Follow these steps and you have created your first two phase commit application:
- Create a new Delphi Project
- Place for (minimum) 2 InterBases Databases a TIBDataBase Component
- Edit the connection String from the TIBDataBase Components to connect diffrent databases
- for example
- database1 ->127.0.0.1:c:\data\employee_1.ib
- database2 ->127.0.0.1:c:\data\employee_2.ib - Place 5 Buttons with following Captions
- add database
- start transaction
- run queries
- commit transaction
- rollback tranaction - Add ONE TIBTransaction component
- Place two TIBQuery Components (you can use later also TIBDataSet for showing data in a gird or what ever)
- edit the SQL Property of each TIBQueryComponent
- update table1 set Field1=’Ernie’ where ID=1
- update table2 set Field1=’Bert’ where ID2
table1 is in this example a table in DataBase1 and
table2 is in this example a table in DataBase2 - set of IBQuery1 properties:
- DataBase -> IBDataBase1
- Transaction -> IBTransaction1 - set of IBQuery2 properties:
- DataBase -> IBDataBase2
- Transaction -> IBTransaction1 - insert this code in the button with the caption “Add DataBase”
IBTransaction1.AddDatabase(IBDatabase1);
IBTransaction1.AddDatabase(IBDatabase2); - insert this code in the button with the caption “start transaction”
IBTransaction1.StartTransaction; - insert this code in the button with the caption “run queries”
IBQuery1.ExecSQL;
IBQuery2.ExecSQL; - insert this code in the button with the caption “commit transaction”
IBTransaction1.Commit; - insert this code in the button with the caption “rollback transaction”
IBTransaction1.Rollback; - in the form event on create open both databases and also on close do not forget to close the databses
- Compile
- Run and have fun
end;
that’s all folks
regards daniel
April 25, 2008 Posted by dmagin | Embarcadero (CodeGear) stuff | | 1 Comment
Member
DelphiLive! 2009
Blogroll
-
Blog Stats
- 46,678 hits
Login
Member of
DelphiExperts Feed- Veranstaltungsbewertung Berlin/Stuttgart
- DelphiExperts Power Workshop Berlin
- DelphiExperts Power Workshop Stuttgart
- ASP.NET mit Delphi Prism
- Einführung in die professionelle Softwareentwicklung unter .NET mit Delphi Prism
- Entwicklung von Webanwendungen mit der VCL für das Web/IntraWeb
- Delphi 2010 – Was ist neu? Ein Intensiv-Workshop
- DelphiExperts Day – Delphi 2010 Dortmund
- DelphiExperts Day – Delphi 2010 Hannover
- DelphiExperts Roadshow – Düsseldorf
Delphifeeds- Technical Leadership #2 December 15, 2009
- Upcoming Michael Rozlog Interview December 15, 2009
- No Access Violation For Me - Return a Property Value From a Nil Delphi Object December 15, 2009
- Migrating to C++Builder 2010" live webinar tomorrow, Tuesday, December 15, 11:00AM PST / 2:00PM EST December 15, 2009
- In-Memory DataSets: ClientDataSet and .NET DataTable Compared: Part 3: Populating In-Memory DataSets December 15, 2009
- Delphi 2010 Handbook Part 1 PDF Available December 14, 2009
- Delphi 2010 Updates 4 and 5 December 14, 2009
- RAD Studio 2010 Update 4: Report on Automatic Incident Reports December 14, 2009
- RAD Studio 2010 Update 4/5 Released December 14, 2009
- Reading about your favorite tool Delphi December 14, 2009
- Delphi/C++Builder 2010 Updates 4 and 5 available December 14, 2009
- Random Thoughts on the Passing Scene #138 December 14, 2009
- Is Embarcadero working on a Garbage Collector for Delphi? December 14, 2009
- Commonly Confused Tidbits re .NET Garbage Collector December 14, 2009
- Delphi 2010 DirectWrite "Hello World" Example December 14, 2009
Pages
Archives
-
Archives
- November 2009 (4)
- October 2009 (3)
- August 2009 (5)
- July 2009 (9)
- June 2009 (2)
- May 2009 (10)
- April 2009 (2)
- March 2009 (4)
- February 2009 (4)
- January 2009 (3)
- October 2008 (2)
- August 2008 (1)
-
Categories
-
RSS
Entries RSS
Comments RSS

