Board index » off-topic » Understanding poCascadeDeletes
Preston
Delphi Developer |
Preston
Delphi Developer |
Understanding poCascadeDeletes2005-05-24 03:37:12 AM off-topic8 I have some nested datasets using ClientDataSets. When I delete the master record I want the detail to be deleted as well. I would have thought setting the poCascadeDelete's option on the provider would do this but it doesn't seem to. Looking at some other posts I see where people are doing this manually in the beforeApplyUpdates Event. Despite these other posts, they don't explicitly state how poCascadeDeletes is supposed to work. Can someone do that? |
Ralf Jansen
Delphi Developer |
2005-05-24 04:05:26 AM
Re:Understanding poCascadeDeletes
Cascading Deletes is a feature of some Databases(I've seen it in Access
and SQLServer). AFAIK datasnap will just disable its own 'can this record be deleted? '-checks and let the database itself handle everything. Preston schrieb: QuoteI have some nested datasets using ClientDataSets. When I delete the master |
Bill Todd
Delphi Developer |
2005-05-24 05:54:35 AM
Re:Understanding poCascadeDeletes
poCascadeDeletes tells the server to delete detail records
automatically when master table records are deleted. To use this option, the provider must represent the master of a master/detail relationship and the database must support cascaded deletes as part of its referential integrity settings. -- Bill Todd (TeamB) {smallsort} |
Preston
Delphi Developer |
2005-05-24 06:05:53 AM
Re:Understanding poCascadeDeletes
I think if you use a standard master detail relationship (not nested)
deleteting the detail works fine.Do nested clientDataSets not do the same thing? I'm using Sybase which supports cascading deletes but it requires me to set up the foriegn key. If I set the key up how does Delphi override that setting. If I set poCascadeDeletes to false won't the DB still cascade deletes? If key is not set up how does Delphi get the delete to cascade? "Bill Todd" < XXXX@XXXXX.COM >wrote in message QuotepoCascadeDeletes tells the server to delete detail records |
Kostas Terzides
Delphi Developer |
2005-05-24 06:27:06 AM
Re:Understanding poCascadeDeletes
Preston wrote:
QuoteI think if you use a standard master detail relationship (not nested) some cases- I don't how sybase calls that). If you choose cascade deletes, then you should choose poCascadeDeletes=True. If you choose No Action (Restrict) then you should choose poCascadeDeletes=False. It depends on business logic. Quote
If key is not set up how does Delphi get the delete to cascade? It doesn't. |
Bill Todd
Delphi Developer |
2005-05-24 06:40:19 AM
Re:Understanding poCascadeDeletes
As Kostas said, poCascadeDeletes is a way to tell the DSP that the
server will take care of deleting the detail records when a master is deleted. -- Bill Todd (TeamB) |
Preston
Delphi Developer |
2005-05-24 06:41:30 AM
Re:Understanding poCascadeDeletesQuoteNo, because it won't let you delete a master record in client side at |
Kostas Terzides
Delphi Developer |
2005-05-24 06:45:47 AM
Re:Understanding poCascadeDeletes
Preston wrote:
QuoteAre you saying the provide would prevent me from deleting the master record |
Preston
Delphi Developer |
2005-05-24 06:57:03 AM
Re:Understanding poCascadeDeletes
Thanks to both of you for being patient and explaing this :-)
Delphi supports deleting detail records if you use a master detail relationship, foreign key on the BD or not. I don't understand why clientDataSets would be any different. I read someone's article in the Borland community that said if you're writing a lot of code to deal with the database then your doing it wrong. If I understand things correctly, I have two options when using nested datasets. 1. I manually delete the records myself in the BeforeRecordUpdate event. This feels wrong ;) 2. I create a foreign key that with cascade deletes enabled. Am I correct in this? "Bill Todd" < XXXX@XXXXX.COM >wrote in message QuoteAs Kostas said, poCascadeDeletes is a way to tell the DSP that the |
Bill Todd
Delphi Developer |
2005-05-24 07:23:01 AM
Re:Understanding poCascadeDeletes
Yes.
-- Bill Todd (TeamB) Preston wrote: QuoteAm I correct in this? |
Kostas Terzides
Delphi Developer |
2005-05-24 07:26:12 AM
Re:Understanding poCascadeDeletesQuoteDelphi supports deleting detail records if you use a master detail QuoteIf I understand things correctly, I have two options when using nested end database doesn't support cascade deletes (the code would easily become very complicated in case the detail table represents the master table of another one, IOW if you have multiple levels of nested datasets) |