I have created a table called Sales_Details_Store1
and a second table called Sales_Store1
.
They are tied together using RI with Sale_ID
(increment 1,1 of bigint type) being the PK in the Sales_Store1
table and the FK being the Sale_ID
(bigint) in the Sales_Details_Store1
table.
When declaring the RI between both tables I had used ON DELETE CASCADE
and ON UPDATE CASCADE
.
The problem I am struggling with is that I need to have my FK updated with the incremented values from the PK, but be able to at the same time update both tables records.
I have had trouble sorting out a trigger or a transaction to do this. Any suggestions?
Sales_Store1
Sale_ID (PK, icrement(1,1), bigint, not null),
Employee_ID (bigint, null),
Customer_ID (bigint, null),
Sale_Date (datetime, null),
Taxes (money, null),
Payment_Type (varchar, null),
Notes (varchar, null),
Tax_Rate (decimal, null),
Tax_Status (int, null)
Sales_Details_Store1
ID (PK, bigint, not null),
Sale_ID (FK, bigint, null),
Product_ID (bigint, null),
Quantity (int, null),
Unit_Price (decimal, null),
Discount (decimal, null),
Date_Allocated (datetime, null),
Inventory_ID (bigint, null)