jmccann
|
| Posted: 06/19/2002, 2:36 PM |
|
Can anyone advise me how to handle Cascading deletions using an Acess database?
If I set up RI within Access and I delete a master record, will Access automatically perform a cascade delete on related records in another table, or do I need to explicity code this in CC?
Anyone have any CC examples if this prefrerred option?
many thanks in advance
|
|
|
 |
Alex Alexapolsky
|
| Posted: 06/20/2002, 6:21 AM |
|
There is an article about this at http://gotocode.com/artlist.asp
|
|
|
 |
jmccann
|
| Posted: 06/20/2002, 2:45 PM |
|
I must be having a bad day!! I looked in link provided and couldnt see any reference to Cascade deletes.
Can you be more specific and direct me to actual article.
Thanks
jmccann
|
|
|
 |
DaveRexel
|
| Posted: 06/20/2002, 4:45 PM |
|
http://www.gotocode.com/art.asp?art_id=122&
Dave
|
|
|
 |
Sean
|
| Posted: 06/21/2002, 4:33 AM |
|
If you set up RI within Access make sure you specify cascade deletes on the master record then the child records in the other table will be deleted when you delete the master record. The database engine does this work for you so you shouldn't have to code anything in CC.
Just in case I missed something though, try adding in a test master record with a couple of child records in the 2nd table and then delete the master record. Check the 2nd table and all of its related records should be deleted as well.
|
|
|
 |
mcurry
|
| Posted: 06/24/2002, 10:41 AM |
|
Sean is correct. Access handles cascaded deletes internally, as long as referential integrity is set in the relationship. That is, using Access, you click Tools|Relationships, right-click to show any tables that are not displayed, then click-drag-drop to establish a relationship. Left-click on the relationship schematic line to edit the properties of the relationship. Select what referential integrity you require, to wit cascaded updates and/or deletes. A cascaded delete is the best way to delete child records (they're not really child records; they are dependent relationships in the aRb model). A cascaded update is a good way to get into bad trouble with an Access DB -- but if you test it out thoroughly, it's the fastest and most dependable method. Depending upon your circumstances, make SURE you have the correct join-type selected, or you will leave orphaned records here-and-there.
|
|
|
 |
|