Options:

1) Intercept the Exception and notify to the operator that he cannot 
delete a customer if he has orders.

2) Execute "Select count(*) FROM Sales_order WHERE ID_Customer = XYZ"
  and if this returns >0 block the Delet customer.

3) Delete Sales_orders with a "Delete Cascade" option on the foreign key

4) Delete Sales_Orders with  a  Delete SQL command execute by delphi in 
a "Before Delete" event on the DataSet in Delphi.

Fabiano


reynaldi81 ha scritto:
>
> hi all, i have this project to build a crm application. my sales order
> table has a foreign key referenced to the customer table. my problem
> is that, everytime i try to delete a customer record, i got this
> "foreign key" exception. how do i know that this customer record is
> not referenced to the sales order record before the user press the
> delete button?
>
> any comments will be highly appreciated
>
> thanks
>
> rey
>
>  

Reply via email to