Informix Error -26021: No operations allowed after truncate or online alter fragment in a transaction.
Cause and resolution
No operations allowed after truncate or online alter fragment in a transaction.
The only allowed operations in a transaction after a truncate or online alter fragment are COMMIT and ROLLBACK.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26021 fires when a statement other than COMMIT/ROLLBACK follows a TRUNCATE/online
ALTER FRAGMENT within the same transaction — per the official guidance.
- A further statement issued after
TRUNCATE/onlineALTER FRAGMENTin the same transaction, other thanCOMMITorROLLBACK, per the official guidance — the direct, only cause.
Solutions / Resolution
- End the transaction with
COMMITorROLLBACKimmediately after aTRUNCATE/onlineALTER FRAGMENT, per the official guidance, before issuing any other statement.
Examples
A statement after TRUNCATE in the same transaction
BEGIN WORK;
TRUNCATE TABLE staging;
INSERT INTO staging VALUES (1);
-- -26021: only COMMIT/ROLLBACK are allowed after the TRUNCATE
Corrected
BEGIN WORK;
TRUNCATE TABLE staging;
COMMIT WORK;
INSERT INTO staging VALUES (1);
Diagnostic Checks
- Check the transaction for any statement issued after a
TRUNCATE/onlineALTER FRAGMENTother thanCOMMIT/ROLLBACK, and reorder the statements.
Related Errors / Related Topics
- -26018 — "Table %s has a referential key constraint and is not empty." A related
TRUNCATE TABLErestriction, on referential integrity rather than post-truncate transaction operations. - -26020 — "Truncating a table with delete trigger requires ALTER privilege." A related
TRUNCATE TABLErestriction, on triggers/privilege rather than post-truncate transaction operations.
A statement other than COMMIT/ROLLBACK followed a TRUNCATE/online ALTER FRAGMENT in
the same transaction — end the transaction immediately after that operation.