Informix Error -958
-958 Temp table <table-name> already exists in session. </table-name>
This statement tries to create a table with the name that is shown, but a temporary table with that name already exists. Only one temporary table with a given name can exist in a session.
Check the spelling of the name. If the name is spelled as you intended, check that a temporary table with the given name does not exist in the session. To review the names of temporary tables, query the systabnames table as follows:
SELECT dbsname, tabname FROM sysmaster:systabnames WHERE tabname = <table-name> </table-name>
If the name exists, review this name by querying the systables table in <dbsname>: </dbsname>
SELECT tabname FROM <dbsname>:systables WHERE tabname = <table-name> </table-name></dbsname>
If the name does not exist in systables (" No rows found "), this table is a temporary table.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-958 fires when CREATE TEMP TABLE names a temp table that already exists in the current
session — per the official guidance, only one temporary table with a given name can exist per
session.
- The same temp table name used twice in one session, per the official guidance — the direct, common cause, often from re-running setup code without first dropping the earlier temp table.
- A name collision with a temp table created earlier in the session for an unrelated purpose, if temp table names aren't scoped/namespaced carefully in a longer script.
Solutions / Resolution
- Check the spelling of the name, per the official guidance.
- Confirm whether a temp table with that name already exists in the session, per the
official guidance, using the documented diagnostic queries:
SELECT dbsname, tabname FROM sysmaster:systabnames WHERE tabname = 'staging_orders'; - Confirm it's actually temporary, not permanent, per the official guidance, with a second
check — if this returns no rows, the table found by the first query is confirmed temporary:
SELECT tabname FROM dbsname:systables WHERE tabname = 'staging_orders'; - Drop the existing temp table, or use a different name, per the official guidance, once confirmed.
Examples
Checking for an existing temp table before creating one
SELECT dbsname, tabname FROM sysmaster:systabnames WHERE tabname = 'staging_orders';
-- if a row comes back, confirm it's temporary (not permanent):
SELECT tabname FROM stores7:systables WHERE tabname = 'staging_orders';
-- "No rows found" here confirms it's the temp table, not a permanent one
Dropping it before re-creating
DROP TABLE staging_orders;
CREATE TEMP TABLE staging_orders (order_id INT, status CHAR(10));
Diagnostic Checks
- Run the official
sysmaster:systabnamesanddbsname:systablesqueries, in that order, to confirm the name collision and that it's genuinely a temp table.
Related Errors / Related Topics
- -856 — "Rowids already exist on table." A related already-exists-style error, for ROWID columns rather than temp table names.
Only one temp table per name per session — the official systabnames/systables two-step query
confirms the collision before dropping or renaming.