Informix Error -877: Isolation Level previously set by "Set Transaction".
Cause and resolution
Isolation Level previously set by "Set Transaction".
Your program attempted to reset the isolation level that a preceding SET TRANSACTION statement established. Do not use a SET ISOLATION statement after a SET TRANSACTION statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-877 fires when SET ISOLATION is issued after a SET TRANSACTION statement already
established the isolation level for the current transaction — per the official guidance, once
SET TRANSACTION has set it, SET ISOLATION shouldn't be used to change it.
SET ISOLATIONissued afterSET TRANSACTIONalready set the isolation level in the same transaction, per the official guidance — the direct, only cause.- Code mixing the older
SET ISOLATIONstatement with the newer, more comprehensiveSET TRANSACTIONstatement, not realizing the two shouldn't both be used to set isolation level within the same transaction.
Solutions / Resolution
- Don't use a
SET ISOLATIONstatement afterSET TRANSACTION, per the official guidance — this is a hard restriction, not a configurable option. - Set the isolation level once, via
SET TRANSACTION, per the official guidance's implied approach, and don't attempt to change it again within the same transaction usingSET ISOLATION. - If a different isolation level is genuinely needed, start a new transaction and set it via
SET TRANSACTIONfrom the beginning of that new transaction.
Examples
The disallowed attempt
BEGIN WORK;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET ISOLATION TO REPEATABLE READ;
-- -877: isolation level was already set by SET TRANSACTION
Corrected — set it once via SET TRANSACTION
BEGIN WORK;
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Diagnostic Checks
- Check whether
SET TRANSACTIONalready set the isolation level earlier in the same transaction, before aSET ISOLATIONstatement is reached.
Related Errors / Related Topics
- -876 — "Cannot issue SET TRANSACTION once a transaction has started." A related
SET TRANSACTIONtiming restriction, about the statement itself coming too late rather than a conflictingSET ISOLATION. - -875 — "Incompatible Access Mode and Isolation Level." A related
SET TRANSACTIONrestriction, on which isolation levels can combine with which access modes.
Set the isolation level once via SET TRANSACTION — don't follow it with SET ISOLATION in
the same transaction.