Informix Error -758: Cannot implicitly reconnect to the new server server_name.
Cause and resolution
Cannot implicitly reconnect to the new server server_name.
If you use the CONNECT TO statement to connect to a server, you cannot implicitly reconnect to another server through one of the DATABASE statements (DATABASE, START DATABASE, and so on). You must switch to it with the SET CONNECTION statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-758 fires when a session established via CONNECT TO (rather than the default implicit
connection) then issues a DATABASE/START DATABASE-family statement that would need to
implicitly connect to a different server — per the official guidance, once a connection was made
explicitly with CONNECT TO, switching servers must also be explicit, via SET CONNECTION.
- A session that used
CONNECT TOto establish its connection, then issuingDATABASE other_dbwhereother_dblives on a different server, per the official guidance — the direct, only cause. - Code written assuming implicit server-switching always works, not accounting for the
difference in behavior once a connection was made via explicit
CONNECT TOrather than the implicit default connection.
Solutions / Resolution
- Use
SET CONNECTIONto switch to the other server explicitly, per the official guidance — this is the documented, required mechanism onceCONNECT TOwas used. - If the other server doesn't yet have its own named connection,
CONNECT TOit first, thenSET CONNECTIONto make it current.
Examples
The disallowed implicit switch
CONNECT TO 'stores7@server_a';
DATABASE other_db@server_b;
-- -758: implicit server switching isn't allowed after an explicit CONNECT TO
Corrected — explicit connection and switch
CONNECT TO 'stores7@server_a';
CONNECT TO 'other_db@server_b' AS conn_b;
SET CONNECTION conn_b;
Diagnostic Checks
- Check whether the session originally connected via
CONNECT TO, and if so, replace any implicit cross-serverDATABASEstatement with an explicitCONNECT TO/SET CONNECTIONpair.
Related Errors / Related Topics
- -1808 — "Reconnect to server_name server to perform the database operation." A closely related error covering this same explicit-connection/implicit-server-switch restriction.
- -1811 — "Implicit connection not allowed after an explicit connection." The general (non-server-specific) form of this same restriction.
Once connected via CONNECT TO, server switching must be explicit — use SET CONNECTION
(after CONNECT TO-ing the target server if needed) instead of an implicit DATABASE switch.