Informix Error -513: Statement not available with this database server.
Cause and resolution
Statement not available with this database server.
You cannot do an xa_open() execution if another database is already open. Make sure that you have closed any open databases before executing xa_open().
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-513, despite its generic-sounding text, is specifically an X/Open XA error: it fires when
xa_open() is called while another database is already open in the session/thread.
xa_open()called without first closing an already-open database connection, per the official guidance — the direct, only cause.- A transaction-manager-driven (XA) application reusing a connection/thread that still has a non-XA (or a different XA) database open from an earlier step in the same session.
- Connection-pooling code that hands XA-managed connections back into a pool without
guaranteeing the previous database was closed before the next
xa_open()on that connection.
Solutions / Resolution
- Close any open database before calling
xa_open(), per the official guidance — issue aCLOSE DATABASE(or equivalent driver/library call) first. - Audit connection-reuse logic in XA-managed connection pools to guarantee each connection is database-closed before it's handed to a new XA transaction branch.
- Avoid mixing non-XA database opens with XA transaction management on the same connection, since the two models expect to own the open/close lifecycle differently.
Examples
Hitting the restriction
/* pseudocode */
sqli_connect("stores7"); /* database already open on this connection */
xa_open(xa_info, rmid, flags);
/* -513: another database is already open */
Corrected sequence
sqli_connect("stores7");
/* ... work done, then ... */
CLOSE DATABASE;
xa_open(xa_info, rmid, flags);
Diagnostic Checks
- Trace the connection's database-open state right before the
xa_open()call to confirm nothing was left open from an earlier statement or a previous pooled use of the connection.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -513 in this set yet.
Despite the generic wording, this is XA-specific: xa_open() requires no database already open
on the connection — close it first.