Informix Error -692
-692 Key value for constraint constraint-name is still being referenced.
You have violated a referential constraint. This situation usually occurs when you are trying to delete a row in a column (parent key) that another row (child key) is referencing. If you are using cascading deletes, database logging must be on.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-692 is the mirror image of -691: it fires when DELETE (or an UPDATE changing a key
value) removes a parent-key row that one or more child rows still reference — per the official
guidance, the same cascading-deletes-require-logging requirement noted for -690/-691 also applies
here.
DELETEon a parent row that child rows still reference, per the official guidance — the ordinary, most common cause.- Cascading deletes attempted on an unlogged database, per the official guidance's shared note — logging must be on for cascading deletes to work.
Solutions / Resolution
- Delete the referencing child rows first, if removing them along with the parent is
genuinely intended:
DELETE FROM order_items WHERE order_id = 42; DELETE FROM orders WHERE order_id = 42; - Or use
ON DELETE CASCADEon the foreign key, if cascading deletion is the desired standing behavior — confirming the database has logging enabled first, per the official guidance's requirement:SELECT name, is_logging FROM sysmaster:sysdatabases WHERE name = 'target_db'; - Find every table that still references the parent row, if it's not obvious from the
schema alone — joined through
sysreferences(ptabidis the referenced/parent table) and filtered to the specific parent table being deleted from:SELECT c.tabname AS referencing_table, k.constrname FROM sysreferences r, sysconstraints k, systables c WHERE r.constrid = k.constrid AND k.tabid = c.tabid AND r.ptabid = (SELECT tabid FROM systables WHERE tabname = 'orders');
Examples
The disallowed delete
DELETE FROM orders WHERE order_id = 42;
-- -692: order_items still has rows referencing order_id 42
Corrected — delete children first
DELETE FROM order_items WHERE order_id = 42;
DELETE FROM orders WHERE order_id = 42;
Diagnostic Checks
- Query the referencing (child) table for rows matching the parent key being deleted.
- Check
is_loggingif cascading deletes are involved and the error persists unexpectedly.
Related Errors / Related Topics
- -690 — "Cannot read keys from referencing table table-name." A related referential- integrity error, sharing this error's cascading-deletes-logging requirement.
- -691 — "Missing key in referenced table for referential constraint constraint-name." The mirror-image violation: inserting an orphaned child, rather than deleting a still-referenced parent.
The mirror image of -691 — delete (or cascade-delete) the referencing child rows before removing the parent row they depend on.