3 Replies Latest reply on Jun 13, 2013 8:55 AM by philmodjunk

    cascading delete problem



      cascading delete problem



                          I am aware that this may be impossible to diagnose without seeing other information but am grasping at straws here.  Can anyone identify from this script how I might be triggering a cascading delete?



      If [ not IsEmpty(EVENT::Event Start Date) and not IsEmpty(EVENT::Event End Date) and not IsEmpty(EVENT::Account Manager ID)

      and not IsEmpty(EVENT::Event Type)and not IsEmpty(EVENT::Event Status) ]

      Freeze Window

      Set Error Capture [ On ]

      Set Variable [ $$TriggersOFF; Value:True ]

      Set Variable [ $STARTDATE; Value:EVENT::Event Start Date ]

      Set Variable [ $ENDDATE; Value:EVENT::Event End Date ]

      Set Variable [ $EVENTID; Value:EVENT::Event ID ]

      Freeze Window

      Go to Layout [ “Event Days” (Event Days) ]

      Perform Find [ Specified Find Requests: Find Records; Criteria: Event Days::event ID: “=$EventID” ] [ Restore ]

      Delete All Records

      [ No dialog ]

                          Exit Loop If
      New Record/Request
                          Set Field
      [ Event Days::date; $STARTDATE ]
      Set Field [ Event Days::event ID; $EVENTID ]
      Set Variable [ $STARTDATE; Value:$STARTDATE+1 ]

      End Loop
                          Go to Layout
      [ “EVENT” (EVENT) ]
      Go to Related Record [ From table: “EVENT”; Using layout: “EVENT” (EVENT) ] Set Variable [ $$TriggersOff; Value:False ]
      Set Error Capture [ Off ]

      End If 


        • 1. Re: cascading delete problem

               Cascading deletes are due to a setting in Manage | Database | Relationships.

               Your delete all records step is deleting records from the Event Days table, so check each relationship that links to an occurrence of Event Days to see which ones specify the "Delete" option for Event Days. (Double click the relationship lines.)

          • 2. Re: cascading delete problem

                 yes.  in the relationship between events and event days, i have "delete related records in this table  when a record is deleted in other table" checked so that when an event is deleted, it will remove the event days display in the calendar display.  is it possible that its working the other way even tho i do not have that option checked on the "event" side of the relationship?

            • 3. Re: cascading delete problem

                   No that should not be possible. That's why there are two check boxes for the delete option in the dialog--one for deletes in each "direction".

                   But out of control cascading deletes can be tricky to track down if you have a lot of different occurrences of the same table. You might just have this option selected somewhere else in your relationship graph and there might even be a "chain" of such options where deleting a record in table 1 deletes records in table 2  triggering a delete of records in table 3... (and each "link" in that chain of deletes could be scattered around in in different parts of your relationship graph)