Re: Informix Transaction in progress (E/SQL)
Posted in 1998
Art S. Kagel wrote: > bruno statuto wrote: > > How can I know that I'm are currently in a transaction > > in esql/c program (sqlca flags ?? this information seems not > > to be in this structure. > > There is no way from within the program proper using the sqlca > structure you must keep track of this yourself. If you execute a > BEGIN WORK and have not COMMIT WORK or ROLLBACK WORK then you are in > a transaction. Otherwise not, set a flag when you BEGIN and clear it > when you COMMIT. You could query the sysmaster tables for your session > id and get your session stats and there is a flag there that will tell > you this but that is expensive and it is not easy to find out your own > session id either. > > If you just want to know if the current database supports transactions, > this can be determined fomr the sqlca.sqlwarn array immediately after > the DATABASE statement or the CONNECT statement if the database name is > included in the CONNECT. See the ESQL/C manual section on sqlca. All this is very true. At a totally pragmatic level, if you want to know whether you are currently in a transaction, try starting one. One of three things happens: * The database has no transaction log, so you get an error -256 (no transactions available) -- check the number; I'm working from memory. * The statement fails because you were already in a transaction. No problem; no damage done. You have the answer you want. And no, I don't immediately recall the error number for this one. * The statement succeeds because you weren't in a transaction. You can rollback (or commit) the empty transaction you just started so that you're in the same state as before. > BTW Flames are VERY rare here, welcome. I prefer my steaks flamed to medium rare, not very rare. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>