Explain the role and purpose of the two codes provided below.
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 role and purpose of the first code is to check the purchase amount of each row. In every row if the purchase amount is less than zero, then raise application error by displaying error message as "Cannot enter a purchase agreement amount less than zero".
The role and purpose of the second code is an insert statement used to insert values in to the table. Here PURCHASE_AGREEMENT is a table. The values in the parenthesis are inserted according to the PURCHASE_AGREEMENT table.
Comments
Leave a comment