OnUpdate (Foreign Key Keyword)
Usage
To specify what happens in the current table when the key value of a referenced record is updated in the foreign table, use the following syntax:
ForeignKey keyname(key_props) References pkg.class(ref_index) [ OnUpdate = onupdate ];
Where onupdate is one of the following:
-
noaction (default) — When an attempt is made to update the key value of a referenced record in the foreign table, the attempt fails.
-
cascade — When the key value of a referenced record is updated in the foreign table, the reference to the foreign table in the referencing record is also updated.
-
setdefault — When the key value of a referenced record is updated in the foreign table, the reference to the foreign table in the referencing record is set to its default value.
-
setnull — When the key value of a referenced record is updated in the foreign table, the reference to the foreign table in the referencing record is set to null.
Details
When the key value of a row in the foreign table is updated, all referencing tables with a foreign key constraint on the foreign table are checked to see if any row references the row being updated. If any such references are found, the OnUpdate action takes effect.
Default
The default is noaction.
See Also
-
Defining a Foreign Key in the InterSystems SQL Reference