Informix Error -32508: Statement is invalid within a transaction.
Cause and resolution
Statement is invalid within a transaction.
You attempted to execute a SET SESSION AUTHORIZATION, SET ROLE, or SET TRANSACTION statement from within an active transaction.
Issue the SET statement at the beginning of the transaction, before a DML statement, such as SELECT or INSERT, makes the transaction active. Otherwise, roll back or commit the transaction before you issue the SET statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-32508 fires when SET SESSION AUTHORIZATION, SET ROLE, or SET TRANSACTION is issued
inside an already-active transaction — per the official guidance.
SET SESSION AUTHORIZATION/SET ROLE/SET TRANSACTIONissued after a DML statement (e.g.SELECT/INSERT) already made the transaction active, per the official guidance — the direct, only cause.
Solutions / Resolution
- Issue the
SETstatement at the beginning of the transaction, before any DML statement, per the official guidance. - Or roll back/commit the current transaction first, per the official guidance,
before issuing the
SETstatement.
Examples
A SET statement issued mid-transaction
BEGIN WORK;
SELECT * FROM orders;
SET ROLE 'sales_admin';
-- -32508: the transaction is already active
Corrected
BEGIN WORK;
SET ROLE 'sales_admin';
SELECT * FROM orders;
Diagnostic Checks
- Check whether a DML statement preceded the
SETstatement in the same transaction, and reorder or commit/rollback first if so.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -32508 in this set yet.
SET SESSION AUTHORIZATION/SET ROLE/SET TRANSACTION was issued inside an
already-active transaction — issue it first, or commit/rollback before issuing it.