Topic: Referential integrity

Hello,

I have a table of service jobs and another table of customers. When I make a new service job, I have a combo box on the job form where I select the customer and that works fine. If I delete the customer from the customer table, it asks me for confirmation and if I allow the deletion, it will delete the customer record even if I have a service job with that customer name on it. The combo box in the service job form then becomes blank (no customer name). I have the customer table set as a dictionary.

I am pretty sure that in a previous version, if I deleted a customer where there is a service job existing with that customer name on it, the software would prevent me from deleting the customer. That is how I would like it to work.

If I change the customer name, the name change is shown in the service job as expected.

Is it possible to prevent customer deletion in the situation I have described.

Thanks for any help,
David

Re: Referential integrity

Hello radsoft

I presume that your 2 tables are linked by a relationship.
So table Customers is child of table Jobs

When creating those 2 tables,  at the time you created the relationship between the two tables, did you check this option
Cascade delete ..... ?

If yes if you delete a customer, all informations in Jobs table about this customer are also dejeted.

This can be a clue to your question

JB

Re: Referential integrity

Hello JB,

Thanks. You have understood the situation. Multiple jobs per customer. I didn't choose cascade delete because I don't want to delete all the service jobs for a customer if I delete that particular customer. I am pretty sure that in an earlier version of MVD, it would not allow deletion of a customer in this situation if cascade delete was not selected.

I am upgrading a deployed application so I will make a sample app tomorrow.

Regards,
David

Re: Referential integrity

radsoft
Hello.


It seem you found a bug.  When you edit foreign key, after that this key loses its constraint.


Please download latest beta version and try to edit foreign key to fix the problem:
https://www.dropbox.com/s/1y0jek64gzfdy … a.zip?dl=0

Dmitry.

Re: Referential integrity

Hello Dmitry,

thank you for the update but it still does the same thing. I got an old version going from February 2016 and this one does not allow me to delete the parent (customer) record if there are child (Service jobs) records present for that particular customer. The relationship looks okay and I don't think I have done anything to it.

Thanks,
David

Re: Referential integrity

radsoft
You should edit foreign key to apply fix.
Please attach your project.

Dmitry.