Informix Error -557: Cannot locate table that is external to the current database after <level-count> levels of synonym mapping.
Cause and resolution
Cannot locate table that is external to the current database after <level-count> levels of synonym mapping.
One of the tables named in this query was in fact a synonym, and it pointed outside the current database. It named another synonym that pointed outside its database, and so on for <level-count> synonyms with no real table being found. The database server has given up on the query in case an endless chain of synonyms exists. </level-count>
To review the synonyms in the current database that refer to external databases, query systables and syssyntable as follows:
SELECT T.tabname synonym, servername, dbname, user, S.tabname FROM systables T, syssyntable S WHERE T.tabtype = 'S' AND T.tabid = S.tabid AND S.btabid IS NULL
To follow a chain of synonyms through external databases, use a similar query in the external database and substitute for servername, dbname, and tabname the values that the preceding query returns each time.
SELECT T.tabname synonym, servername, dbname, user, S.tabname FROM dbname@servername:systables T, dbname@servername:syssyntable S WHERE T.tabtype = 'S' AND T.tabname = 'tabname' AND T.tabid = S.tabid
When this query returns no row, the requested tabname is not defined as a synonym in that database (it is a table, a view, or not defined).
</level-count>Oninit® Troubleshooting Guidance
Reasons / Common Causes
-557 fires when a query names a synonym that points to another database, and that database's
matching name is itself another synonym pointing further out, repeating through <level-count>
hops without ever reaching a real table — the server gives up rather than risk following an
endless chain, per the official guidance.
- A synonym chain crossing several external databases, each hop itself a synonym rather than a real table, that either genuinely never terminates or simply exceeds the server's resolution depth.
- A synonym left pointing at a name that was renamed, dropped, or replaced with another synonym in a remote database, breaking what used to be a chain that terminated correctly.
- Circular synonym references across two or more databases, which would never resolve no matter how many levels the server was willing to follow.
Solutions / Resolution
- Trace the synonym chain in the current database, per the official guidance's documented
diagnostic query, to find where it first points externally:
SELECT T.tabname synonym, servername, dbname, "user", S.tabname FROM systables T, syssyntable S WHERE T.tabtype = 'S' AND T.tabid = S.tabid AND S.btabid IS NULL; - Follow the chain into each external database, per the official guidance's documented
diagnostic query, substituting the
servername/dbname/tabnamefound at each hop:
per the official guidance, an empty result at some hop means that name is either a real base table, a view, or simply undefined in that database — either the chain's true endpoint or where it's broken.SELECT T.tabname synonym, servername, dbname, "user", S.tabname FROM dbname@servername:systables T, dbname@servername:syssyntable S WHERE T.tabtype = 'S' AND T.tabname = 'tabname' AND T.tabid = S.tabid; - Fix or shorten the chain once the break (or the circularity) is located — point the synonym directly at the real table, or remove a stale intermediate hop.
Examples
Tracing the chain from the current database
SELECT T.tabname synonym, servername, dbname, "user", S.tabname
FROM systables T, syssyntable S
WHERE T.tabtype = 'S' AND T.tabid = S.tabid AND S.btabid IS NULL;
Following it into the next external database
SELECT T.tabname synonym, servername, dbname, "user", S.tabname
FROM other_db@remote_server:systables T, other_db@remote_server:syssyntable S
WHERE T.tabtype = 'S' AND T.tabname = 'orders_synonym' AND T.tabid = S.tabid;
Diagnostic Checks
- Run the official
systables/syssyntablequery in the current database to find the first external hop. - Repeat the cross-database variant of the query at each subsequent hop, until either a real table/view is found or the chain is confirmed circular.
Related Errors / Related Topics
- -556 — "Cannot create, drop, or modify an object that is external to current database." A related cross-database error, about attempting a write against a read-only external object rather than an unresolvable synonym chain.
Trace the chain with the official systables/syssyntable queries, hop by hop across databases,
to find where it breaks or loops.