Solved

2 phase commit by example

Posted on 2001-06-14
7
1,216 Views
Last Modified: 2008-02-01
Can anyone explain me 2phase commit by small example?
I've two database server base1 and base2.How can i implement 2 phase commit?Pls expalin me with a small live example used in industry..I'm using sql 2000.
0
Comment
Question by:vivekkj
7 Comments
 
LVL 2

Expert Comment

by:ZhongYu
ID: 6194057
What you want to do?

To phase commit is implemented in MS DTC (Distributed Transaction Coordinator). As a programmer and administrator, you do not have to do it yourself. If you use middle tier transaction logic, the only thing you have to do is to implement transaction in your component.

 

0
 
LVL 1

Expert Comment

by:mgrajkumar
ID: 6195487
Just do
Begin distributed Tran
 
<Sql Statements>

Commit tran
or
Rollback
         
0
 
LVL 1

Expert Comment

by:mgrajkumar
ID: 6195489
Just do
Begin distributed Tran
 
<Sql Statements>

Commit tran
or
Rollback
         
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 18

Expert Comment

by:nigelrivett
ID: 6195858
Why do you want a two phase commit?

Basically this is only used where the transaction controller doesn't have close control over all entities involved in the transaction.

The basic idea is that the first phase is 'are we all ready to commit?', second phase 'go ahead and commit?'
Before responding to the first phase the entity is expected to prepare the system so that nothing will hold up the commit.
0
 
LVL 2

Accepted Solution

by:
sefa earned 100 total points
ID: 6199744
suppose you have two SQL Servers server_A and server_B
suppose you have two databases server_A.db_1 and server_B.db_2
suppose you have two table server_A.db_1..table_1 and server_B.db_2..table_2

if you want to insert a row into server_A.db_1..table_1 and update a row from server_B.db_2..table_2
in the same transaction you must use distrubted transaction. to do so,
you should place your insert and update sql statements into

BEGIN DISTRIBUTED TRANSACTION
insert into server_A.db_1..table_1 values('hello')
update server_B.db_2..table_2 set my_col='hello'
.
.
.
-- COMMIT DISTRIBUTED TRANSACTION
-- or if any error occured then
-- ROLLBACK DISTRIBUTED TRANSACTION

In this example both insert and update are succesful or not.

to support this feature MS DTC service must be running.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6900192
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20109559.html
http://www.experts-exchange.com/questions/Q.20118141.html
http://www.experts-exchange.com/questions/Q.20124163.html
http://www.experts-exchange.com/questions/Q.20125452.html
http://www.experts-exchange.com/questions/Q.20129840.html
http://www.experts-exchange.com/questions/Q.20135140.html
http://www.experts-exchange.com/questions/Q.20135933.html
http://www.experts-exchange.com/questions/Q.20191895.html
http://www.experts-exchange.com/questions/Q.20218509.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20228009.html
http://www.experts-exchange.com/questions/Q.20225905.html
http://www.experts-exchange.com/questions/Q.20278235.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6992946
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MS SQL Bulk load data error 5 33
Full Text Search string 5 33
sql query 7 35
SQL index creation taking an abnormally long time 2 19
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now