Topic: Cascade Delete Bug

Hi guys
First off I don't know whether its a bug or I'm doing something wrong.
Suppose you have 2 tables related to each other ( Parent - Child)
in one table you have many different entries .
one entry is a combobox related to another table.
When you choose cascade delete in the relationship filed, and then you delete the data of a combobox, all the entries for that record are deleted.
Is it possible using a script that when you choose cascade delete, only the data regarding to that specific combobox are deleted ?
Am I clear or should I attach a sample ?
thanks

Re: Cascade Delete Bug

It is not a bug, it is the very intended purpose of the option cascade delete!! Deleting data linked with a relationship (foreign key) could lead to orphan entries.

If you want to delete data in a parent table while keeping the data from children tables, do not use delete cascade.

https://www.databasestar.com/on-delete-cascade/
https://www.sqlite.org/foreignkeys.html
https://www.sqlitetutorial.net/sqlite-foreign-key/

Re: Cascade Delete Bug

Thanks for the reply
I know that I can choose not to use cascade.
I have attached a sample.
suppose you record something wrong in a (combobox1 Mainform) and you want to delete it while keeping other data.
If I don't use cascade delete then I get an error
If I use cascade delete all the data are lost.
What I need to do is that when I delete the data in (Tablegrid1 Bank) other data that are recorded should be intact and only the data of (combobox1 Mainform) should be cleared.
Do you think it can be done using a script?
thanks a lot

Post's attachments

Attachment icon Cascade.zip 335.28 kb, 20 downloads since 2024-03-10 

4 (edited by pavlenko.vladimir.v 2024-03-10 14:10:33)

Re: Cascade Delete Bug

identity wrote:

Thanks for the reply
I know that I can choose not to use cascade.
I have attached a sample.
suppose you record something wrong in a (combobox1 Mainform) and you want to delete it while keeping other data.
If I don't use cascade delete then I get an error
If I use cascade delete all the data are lost.
What I need to do is that when I delete the data in (Tablegrid1 Bank) other data that are recorded should be intact and only the data of (combobox1 Mainform) should be cleared.
Do you think it can be done using a script?
thanks a lot

А Вам и не нужно ни чего удалять, просто перейдите в редактирование записи и в ComboBox выберете пустое поле, нажмите сохранить
 
And you don’t need to delete anything, just go to edit the entry and select an empty field in the ComboBox, click save

5 (edited by pavlenko.vladimir.v 2024-03-10 12:54:09)

Re: Cascade Delete Bug

https://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=10314&download=0

Post's attachments

Attachment icon 2024-03-10_17-51-34.png 48.69 kb, 4 downloads since 2024-03-10