Explain the role and purpose of the two codes provided below. (5 marks)
Create or Replace Trigger Purchase_Entry
After Insert or Update of Purchase_Amt on PURCHASE_AGREEMENT
For Each Row
Begin
if(:New.Purchase_Amt < 0) Then
RAISE_APPLICATION_ERROR(‐20100,
'Cannot enter a purchase agreement amount less than zero.');
end if;
End;
insert into PURCHASE_AGREEMENT values (559, '27 May 2020', ‐1, 12350,'C122',1)
The purpose of first code is to check the validity of the data that the inserting data is valid or not. Means if any new purchase is getting place then the purchase amount can not be zero or less than zero, it must be some positive value. So, if it is found that the purchase amount is less than 0 then it will show error, and user will see a message that is "Can not enter a purchase agreement amount less than zero."
The second code is explaining that whenever new purchase is getting place then insert table must insert a transaction record which will be reflected into the database and this mentioned record will be visible into the table.
Comments
Leave a comment