Update Primary Key
Posted in 1998
Topics: SQL Development & Query Writing, Triggers, Constraints & Referential Integrity
ERwin will generate a trigger to cascade the primary key change like this:
create trigger tU_product_types UPDATE on product_types
referencing OLD as deleted NEW as inserted
for each row
-- ERwin Builtin Tue Mar 24 08:55:50 1998
-- UPDATE trigger on product_types
-- ERwin Builtin Tue Mar 24 08:55:50 1998
-- product_types supplier_prod_type ON PARENT UPDATE CASCADE
when(
-- %JoinPKPK(deleted,inserted," <> "," or ")
deleted.product_type_id <> inserted.product_type_id
)
(update supplier_prod_type
set
-- %JoinFKPK(supplier_prod_type,inserted," = ",",")
supplier_prod_type.product_type_id = inserted.product_type_id
where
-- %JoinFKPK(supplier_prod_type,deleted," = "," and")
supplier_prod_type.product_type_id = deleted.product_type_id
);
Hope this helps,
Gerry Schuil
---------------------- Forwarded by Gerry Schuil/ham/LIC on 27 03 98 09:04
---------------------------
morrisma@sterlingdi.com on 27 03 98 05:42:47
To: informix-list@iiug.org
cc: (bcc: Gerry Schuil/ham/LIC)
Subject: Update Primary Key
Hello!
I have a set of four tables. The first has a primary key and the other
three reference that key.
How can I modify a primary key value and have that cascaded to all the
referencing data? The CASCADE keyword seems to apply only to delete not
update. Is there another way?
TIA
Mike Morris