Informix Error -784
-784 Cannot detach because of the existing referential constraints.
Existing referential constraints do not allow you to perform a detach. You must drop the referential constraints before you perform the detach on the dbspace/partition or table.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-784 fires when ALTER FRAGMENT ... DETACH is attempted on a dbspace/partition or table that has
existing referential constraints — per the official guidance, these constraints must be dropped
before the detach can proceed.
- A foreign key referencing (or referenced by) the fragment/table being detached, per the official guidance — the direct, only cause.
- A detach attempted without accounting for the referential relationships the fragment's data participates in, since detaching effectively removes that data from the parent table's scope.
Solutions / Resolution
- Drop the referential constraints before performing the detach, per the official
guidance:
ALTER TABLE order_items DROP CONSTRAINT fk_order_items_orders; ALTER FRAGMENT ON TABLE orders DETACH east_partition orders_east; - Re-establish the referential constraint afterward, if it's still needed and the detached
data's new table (or the remaining fragmented table) should still enforce it:
ALTER TABLE order_items ADD CONSTRAINT FOREIGN KEY (order_id) REFERENCES orders(order_id) CONSTRAINT fk_order_items_orders; - Identify every referential constraint involving the fragment/table before attempting the
detach:
SELECT constrname FROM sysconstraints WHERE tabid = (SELECT tabid FROM systables WHERE tabname = 'orders') AND constrtype = 'R';
Examples
Dropping the constraint, detaching, then re-adding it
ALTER TABLE order_items DROP CONSTRAINT fk_order_items_orders;
ALTER FRAGMENT ON TABLE orders DETACH east_partition orders_east;
ALTER TABLE order_items ADD CONSTRAINT
FOREIGN KEY (order_id) REFERENCES orders(order_id) CONSTRAINT fk_order_items_orders;
Diagnostic Checks
- Query
sysconstraintsfor referential constraints (constrtype = 'R') involving the table/fragment being detached, before attempting the detach.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -784 in this set yet.
Drop the referential constraint first, detach, then re-add the constraint afterward if it's still needed.