Subject | RI using triggers |
---|---|
Author | Nols Smit |
Post date | 2006-04-06T07:24:52Z |
I have a BEFORE DELETE trigger on table UPDATERS, giving the user a better indication why RI will not allow him to delete a record, e.g.
AS
BEGIN
/* Trigger body */
if (exists(Select Updater_ID from Addresses where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table Addresses';
if (exists(Select Updater_ID from Geosites where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table Geosites';
if (exists(Select Updater_ID from Photos where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table Photos';
if (exists(Select Updater_ID from SiteJunction where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table SiteJunction';
END
Is there a way I can modify this trigger so the user can get an indication which records are using the primary key of table UPDATERS as a foreign key?
Something like
if (exists(Select Updater_ID from Addresses where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table Addresses, ID = ' || Addresses.ID;
Regards,
Nols Smit
Disclaimer Legal Notice:
By having opened and read this electronic mail, you are deemed to have
understood and accepted all disclaimers and conditions pertaining to
electronic mail emanating from, and received by The Council for Geoscience,
further detail of which may be viewed at the following hyperlink:
http://www.geoscience.org.za/disclaimer.htm
[Non-text portions of this message have been removed]
AS
BEGIN
/* Trigger body */
if (exists(Select Updater_ID from Addresses where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table Addresses';
if (exists(Select Updater_ID from Geosites where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table Geosites';
if (exists(Select Updater_ID from Photos where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table Photos';
if (exists(Select Updater_ID from SiteJunction where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table SiteJunction';
END
Is there a way I can modify this trigger so the user can get an indication which records are using the primary key of table UPDATERS as a foreign key?
Something like
if (exists(Select Updater_ID from Addresses where Updater_ID = Old.id)) then
exception Code_ID 'Updater_ID in use in table Addresses, ID = ' || Addresses.ID;
Regards,
Nols Smit
Disclaimer Legal Notice:
By having opened and read this electronic mail, you are deemed to have
understood and accepted all disclaimers and conditions pertaining to
electronic mail emanating from, and received by The Council for Geoscience,
further detail of which may be viewed at the following hyperlink:
http://www.geoscience.org.za/disclaimer.htm
[Non-text portions of this message have been removed]