Informix Error -878: Invalid operation for a READ-ONLY transaction.
Cause and resolution
Invalid operation for a READ-ONLY transaction.
You specified a READ-ONLY transaction in a SET TRANSACTION statement and then attempted to alter the database. In other words, READ-ONLY ensures that you can read data, but you cannot alter data. If you want to alter the data, specify READ WRITE in the SET TRANSACTION statement. If you only want to read the data, correct your program so that it does not attempt to alter the data.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-878 fires when a transaction started with SET TRANSACTION READ ONLY attempts a data-altering
operation — per the official guidance, READ ONLY permits reading data but not altering it.
- An
INSERT/UPDATE/DELETE(or other data-altering statement) attempted within aREAD ONLYtransaction, per the official guidance — the direct, only cause. - A transaction started
READ ONLYout of habit or a copy-pasted template, when the actual workflow needed to write data.
Solutions / Resolution
- Specify
READ WRITEinSET TRANSACTION, per the official guidance, if altering data is genuinely needed. - Or correct the program so it doesn't attempt to alter data, per the official guidance, if
READ ONLYwas intentional and the write attempt was itself the actual bug.
Examples
The disallowed attempt
BEGIN WORK;
SET TRANSACTION READ ONLY;
UPDATE orders SET status = 'shipped' WHERE order_id = 42;
-- -878: READ ONLY transactions can't alter data
Corrected — READ WRITE if altering data is intended
BEGIN WORK;
SET TRANSACTION READ WRITE;
UPDATE orders SET status = 'shipped' WHERE order_id = 42;
Diagnostic Checks
- Check whether the transaction was started
READ ONLY, and confirm whether the intent was actually to read only, or whetherREAD WRITEshould have been specified instead.
Related Errors / Related Topics
- -875 — "Incompatible Access Mode and Isolation Level." A related
SET TRANSACTIONrestriction, on isolation-level compatibility rather than a write attempted withinREAD ONLY.
READ ONLY transactions can never alter data — specify READ WRITE if writing is genuinely
needed.