>Hi Everyone,
>
>In a cascading delete, is there a generally accepted technique to prevent the parent from being deleted if a delete trigger on one of the child records fails. Currently, the parent is deleted regardless of whether all of the child records are deleted or not. This results in orphaned child records in the table (not good.)
Not quite sure what you're asking here. In VFP all RI is handled programmatically, typically by code in stored procedures in the database's .DBC.
VFP automatically generates code here to handle RI requirements. A well regarded replacement is available at
http://home.twmi.rr.com/ssawyer/content/ricode.htmIf these don't meet your needs, you can write your own custom RI code either as a stored procedure or procedurally in your application. Pseudocode:
BEGIN TRANSACTION
DELETE FROM ChildTable WHERE ForeignKey = SomeValue
SELECT SomeColumn FROM ChildTable WHERE ForeignKey = SomeValue
IF _TALLY > 0
ROLLBACK
ELSE
END TRANSACTION
DELETE FROM ParentTable WHERE PrimaryKey = SomeValue
ENDIF
You can dress up the above with a transaction around the parent delete, custom ERROR handling, etc.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up