Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When to use GetObjectContext?

Status
Not open for further replies.

BoxsterBoy

Programmer
Aug 8, 2001
1
0
0
GB
I am writing a number of components which will run in MTS.

I know that I need to call GetObjectContext / SetComplete / SetAbort in the public methods of these objects, but do I also need to do this in the private methods that the public methods call? What about functions/subroutines that are in normal bas modules but are called by the public/private methods?

Thanks for any help,
Andy
 
Andy,

There is slightly more to this then you are thinking. As part of your system design you need to think about the transactional desighn. For example If I want to update 2 tables I could do this in one transaction, so that if anything goes wrong with either update then niether is updated. or I could design it so that they are seperate so if something goes wrong in one update the other update is still completed.

Once you know where your transaction baoundaries are you can start implementing this in code. When you create an object in MTS call getObjectContext, in effect this is the start of your transaction. when the transaction boundary is reached you call SetComplete if it was successfull or setAbort if it fails. Any made between these two points will be commited or aborted at this point.

Dan.

 
SetComplete/SetAbort will tell the MTS executive whether the operation is successful by changing a flag in object context.
Even if your operation doesnot need transaction eg. getting data from DBMS,you can also call SetComplete/SetAbort:
....
try
//get_data from db
SetComplete;
except
SetAbort;
raise;
end
....
Maybe it is not necessary but it will simplify your programming without any side effect.

Regards! zallen@cmmail.com
Long live of freedom!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top