Informix Error -377
-377 Must terminate transaction before closing database.
This statement (DATABASE, CREATE DATABASE, or CLOSE DATABASE) cannot be executed until the current transaction is finished.
Use either COMMIT WORK or ROLLBACK WORK and then close the database.
If you export a database and then import it, large-object handles (for images) will be different after you import the database. Therefore, if you use static html references for images and export the database and then import it, you will have to determine the new large-object handle for each static html reference.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-377 fires when DATABASE, CREATE DATABASE, or CLOSE DATABASE is attempted while a
transaction is still open — each of these statements needs to leave the database in a settled
state, which an open, undecided transaction prevents.
- A
BEGIN WORKwith no matchingCOMMIT WORK/ROLLBACK WORKbefore attempting to close or switch databases. - An error-handling path that closes the database on failure without first rolling back a transaction that was left open by the failure itself.
- Application logic assuming database switches are always safe, without checking transaction state first.
Solutions / Resolution
- Complete the current transaction with
COMMIT WORKorROLLBACK WORK, per the official guidance, before attemptingDATABASE,CREATE DATABASE, orCLOSE DATABASE. - In error-handling paths, always roll back an open transaction before closing the database, rather than assuming the close alone is sufficient cleanup.
Examples
Committing before closing
BEGIN WORK;
UPDATE orders SET status = 'shipped' WHERE order_id = 1001;
COMMIT WORK;
CLOSE DATABASE;
The disallowed direct attempt
BEGIN WORK;
UPDATE orders SET status = 'shipped' WHERE order_id = 1001;
CLOSE DATABASE;
-- -377: the transaction is still open
Rolling back in an error-handling path
BEGIN WORK;
UPDATE orders SET status = 'shipped' WHERE order_id = 1001;
-- on error:
ROLLBACK WORK;
CLOSE DATABASE;
Diagnostic Checks
- Check whether a
BEGIN WORKhas an unmatchedCOMMIT WORK/ROLLBACK WORKbefore the failing statement. - Review error-handling paths for a missing rollback before a database close.
Related Errors / Related Topics
- -358 — "Must close current database before CREATE, START or ROLLFORWARD." A related database-session-state restriction — both concern the required sequencing around switching or closing a database.
- -359 — "Cannot drop or rename the current database or any open database." Another related database-lifecycle restriction, on the drop/rename side.
Always resolve an open transaction with COMMIT WORK or ROLLBACK WORK before switching or
closing a database — especially in error-handling paths, where a rollback is easy to forget.