Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking before deleting a record required.

Status
Not open for further replies.

essa2000

Programmer
Dec 6, 2000
299
CA
Dear Programmers:
I am going to delete one record , I want to check that if this record has been used in other data , I mean it has been referenced in other table as a foriegn Key . Then before deleting the record it give me an error. I want to use this technique in a stored Procedure which is used to
delete the record.

Thanks in advance.

Regards ,
essa2000
 
if you try to delete a record that is being refrenced by a foreign key you will get an error and the delete will not happen. No programming is required for this. Ruairi
ruairi@logsoftware.com
Experienced with:

VB6, SQL Server, QBASIC, C(unix), MS Office VBA solutions

ALSO: Machine Control/Automation using GE and Omron PLC's and HMI(human machine interface) for industrial applications
 
That is true if you have actually declared the referential integrity in the DDL, but not true if you have not.

You'll want a Delete trigger on the subject table that takes care of looking in the other tables for child records.

Robert Bradley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top