locked
Trigger Help RRS feed

  • Question

  • User1266736465 posted

    Has any one done a trigger that do not allow the app user or via the query analyser to delete a record once such record id is linked to another data table.

    explain:
    I have POS with the following tables

    Table->Customers data with Primary indexed key on the indentity int column [CustomerId]
    Table->Orders data with Primary indexed key on the indentity int column [OrderId] ->Contains column Customers->CustomerId
    Table->Payments data with Primary indexed key on the indentity int column [PaymentId] -> Contains relation to column orders->OrderId

    I understand that by setting Foreign Key this would be possible but it is too late now because the way the tables were setup.

    That is why I am trying to set up a trigger in the customer data table that do not allow to delete such customer if customer data is linked to an order and payment data.
    The same way goes for the payment table data if payment applied is linked to an order or customer data do not allow to delete such payment.

    Please provide sample

    Thanks

    Monday, May 25, 2020 2:24 PM

Answers