Triggers and Foreign Key Constraints

  • I'm writing a trigger to update information in database B from database A.

    Database B has 2 tables

    Table A has a primaryKey CustomerID and Table B has a foreignKey Customer_ID, these tables are related 1-->M.

    The trigger that I've written updates all customer information apart from the CustomerID field.

    I get a FK_Constraint error message when I try to change the Customer_ID field in TableA because no FK exists in TableB.

    Is there anyway that I can update the customerID in both tables?

    Thanks for anything.

    Theo

     

     

  • It's not clear what are you trying to do, but anyway CustomerId you are applying in TableB must be RETRIEVED from TableA.

    If you are trying to update TableA with some CustomerId values coming from somewhere else it's wrong by definition.

    _____________
    Code for TallyGenerator

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply