Informix Error -327
-327 Cannot unlock table table-name within a transaction.
The statement UNLOCK TABLE is not allowed within a transaction, that is, following the execution of BEGIN WORK. You can still use LOCK TABLE when you use transactions, but the table will be unlocked automatically when the transaction ends. All locks are released at the end of a transaction. In an ANSI-compliant database, BEGIN WORK is not used, a transaction is always in effect, and the UNLOCK TABLE statement is never used.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-327 reflects an asymmetry in how table locking interacts with transactions: LOCK TABLE is
allowed inside a transaction, but UNLOCK TABLE isn't — because table locks acquired within a
transaction are released automatically when the transaction ends (commit or rollback), and an
explicit early unlock would undermine that guarantee.
- An explicit
UNLOCK TABLEstatement issued afterBEGIN WORK— the direct cause. - Application logic ported from a non-transactional workflow, where explicit lock/unlock pairs were used, without adjusting for the fact that a transaction now wraps the same logic.
- Working in an ANSI-compliant database, where transactions are always implicitly active —
UNLOCK TABLEis never valid there, since there's no non-transactional state to return to.
Solutions / Resolution
- Remove the explicit
UNLOCK TABLEcall inside the transaction, per the official guidance — the lock releases automatically at commit or rollback. - If early release of the lock is genuinely needed, commit or roll back the transaction at that point instead rather than trying to unlock a single table mid-transaction.
- In an ANSI-compliant database, don't use
UNLOCK TABLEat all — restructure locking expectations around the fact that transactions are always active there.
Examples
Removing an unnecessary explicit unlock
BEGIN WORK;
LOCK TABLE inventory IN EXCLUSIVE MODE;
UPDATE inventory SET quantity = quantity - 1 WHERE part_id = 42;
UNLOCK TABLE inventory;
-- -327: can't unlock explicitly inside a transaction
COMMIT WORK;
Fix — let the commit release the lock:
BEGIN WORK;
LOCK TABLE inventory IN EXCLUSIVE MODE;
UPDATE inventory SET quantity = quantity - 1 WHERE part_id = 42;
COMMIT WORK;
-- the lock is released automatically here
Diagnostic Checks
- Check whether
UNLOCK TABLEis being called after aBEGIN WORKwith no intervening commit/rollback. - Confirm whether the database is ANSI-compliant — if so,
UNLOCK TABLEshould never be used at all.
Related Errors / Related Topics
- -291 — "Cannot change lock mode of table." Another table-locking-lifecycle restriction, in the same general locking-and-transactions family.
Let the transaction's commit or rollback release the lock — UNLOCK TABLE mid-transaction is
never valid, whether or not the database is ANSI-compliant.