Informix Error -535: Already in transaction.
Cause and resolution
Already in transaction.
This BEGIN WORK statement is redundant; a transaction is already in progress. If this is a program, review its logic to make sure it has not accidentally failed to end the previous transaction.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-535 fires when BEGIN WORK is issued while a transaction is already open on the session —
Informix doesn't support nested transactions, so a second BEGIN WORK before the first is
closed is redundant and rejected.
- A program's logic accidentally omits
COMMIT WORK/ROLLBACK WORKat the end of a prior transaction, per the official guidance — the nextBEGIN WORKthen finds one still open. - An error-handling path that skips the closing
COMMIT/ROLLBACK, so a transaction that should have ended on failure is left open going into the next operation. - Nested function/procedure calls each issuing their own
BEGIN WORK, without one level being aware the caller already opened a transaction.
Solutions / Resolution
- Review the program's transaction logic, per the official guidance, to confirm every
BEGIN WORKhas a matchingCOMMIT WORKorROLLBACK WORKon every code path, including error-handling paths. - Track transaction state explicitly in application logic if a routine might be called either standalone or nested inside a caller's own transaction, rather than relying on a probe query — Informix has no supported DBINFO/SQLCA field for "is a transaction currently open."
- Don't nest
BEGIN WORKcalls — structure the code so only the outermost caller manages the transaction boundary, and inner routines simply participate in the caller's already-open one.
Examples
The redundant BEGIN WORK
BEGIN WORK;
UPDATE orders SET status = 'shipped' WHERE order_id = 42;
-- error-handling path skips ROLLBACK WORK here by mistake
BEGIN WORK;
-- -535: a transaction from the earlier BEGIN WORK is still open
Corrected — close the transaction on every path
BEGIN WORK;
UPDATE orders SET status = 'shipped' WHERE order_id = 42;
-- on error:
ROLLBACK WORK;
-- on success:
COMMIT WORK;
Diagnostic Checks
- Trace every code path out of the transaction block, especially error/exception handlers,
to confirm each one reaches a
COMMIT WORKorROLLBACK WORK. - Look for nested routines that each issue their own
BEGIN WORK, and consolidate to a single outer transaction boundary.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -535 in this set yet.
Informix transactions don't nest — trace every exit path (including error handlers) from the prior transaction to find the missing COMMIT/ROLLBACK.