HElp with deletion in master detail

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

HElp with deletion in master detail

Post by brace » Wed 12 Jun 2019 16:45

Hi, as a continuation of this topic viewtopic.php?t=27242

i tried to implement a sample in which master detail relationship is done with MasteSource.

when i delete a master record anyway i do not see that the deletion of the details is done correctly.

i will send the sample to support.

i hope you can reply since i am stuck.

THanks.

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: HElp with deletion in master detail

Post by Stellar » Thu 13 Jun 2019 14:11

When creating the "FK_Detailtbl_Mastertbl" foreign key constraint, add the DELETE CASCADE option. Cascade deletion will help retain the link integrity of your database.
For example, here's a foreign key constraint creation script:

Code: Select all

ALTER TABLE [dbo].[Detailtbl]  WITH CHECK ADD  CONSTRAINT [FK_Detailtbl_Mastertbl] FOREIGN KEY([ID_MASTER])
REFERENCES [dbo].[Mastertbl] ([ID_MASTER]) ON DELETE CASCADE

brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

Re: HElp with deletion in master detail

Post by brace » Fri 14 Jun 2019 08:08

Thanks for the reply.
So you mean that there is no way to obtain deletiong thgouh "cached updates" withotu using the cascade delete option?

I thought that teh dataset could handle this.

Thanks.

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: HElp with deletion in master detail

Post by Stellar » Wed 19 Jun 2019 15:38

The logic in your sample differs from the logic in the sample described in the viewtopic.php?t=27242 topic. When you delete records from the master dataset. you have to manually delete records from the detail dataset as well. SDAC doesn't automatically delete records from the detail dataset.

Post Reply