I have 2 tables invoice and invoice item The invoice table contains Invoice_Number as primary key and invoice date and Paid_YN, the invoice_item table contains Invoice_Number as primary key and quantity_Sold, and item_Number as primary key also. I want to creat trigger which will not allow records to be inserted/updated/deleted in the invoice item table if the corresponding invoice has been paid.
I tried this code which is not perfect
Create trigger TR_Not_allow
for each row
Select Paid_YN Into V-paid_YN
on Invoice_item.Invoice_Number = Invoice.Invoice_Number
if Paid_YN = 'True' then
Insert into Invoice_Item (