Re: ESQL/C transaction
Posted in 1993
In article <1rgqc7INN72m@emory.mathcs.emory.edu> unifi!goofy.unifi.com!bharat@uunet.UU.NET (Bharat Shah) writes: >I have multiple libraries of ESQL-C functions. A lot of them call one >another. Some functions also have begin/rollback/commit transactions. >Problem I face is before starting transaction, how can I detect that >a transaction has already been started ?? >Multiple "begin work"s obviously (and correctly) is unsuccessful and >returns error. > I would suggest that you define a global variable to tell you if you have started a transaction already or not; when you "begin work" you would set this flag, and unset it when you do a "commit/rollback work." Just make sure that you check the flag before you issue the "begin work." At a deeper level, though, you may want to spend some time thinking about the structure of your code. I have found that when I want to end a transaction in a function other than the one that began it, the code is invariably poorly structured to begin with. This normally means that some rethinking is in order, with an eye to simplifying and modularizing the code. I'm not trying to criticize your code or anything, as I've been in your situation more times than I care to remember. But, like I said, I have never seen a situation where the real problem was other than poorly structured code. By the way, this applies to every language I've used, not just ESQL/C. Good luck, David Coburn coburn@informix.com Informix Software, Inc. ...uunet!infmx!coburn ========================================================================= Any opinions expressed here are not necessarily those of Informix (or for that matter, anybody else). =========================================================================