Answer to Question #273031 in Databases | SQL | Oracle | MS Access for QueenNerd

Question #273031

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)


1
Expert's answer
2021-12-01T00:53:06-0500

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.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS