Oracle SQL/TRIGGER: Write a command to create a trigger on the loan table that e
ID: 3599613 • Letter: O
Question
Oracle SQL/TRIGGER: Write a command to create a trigger on the loan table that enforces the business
rule "The due date for the return of the tool is set based on the employee’s estimate of how
long they will need the tool or the due date is set to 7 days from the checkout date, whichever
is sooner. Then write commands to test the functionality you created.
Explanation / Answer
EXPLANATION:
NAME OF THIS TRIGGER IS 'DDATE' AND IT'S BEING EXECUTED BEFORE ANY INSERTION OPERATION.IN IT'S EXECUTION IT CHECKS WHETHER THE DUE DATE GIVEN BY THE EMPLOYEE IS GREATER THAN THE SYSTIME +7(MAXIMUM ALLOWABLE TIME) .IF IT IS GREATER THEN IT ASSIGN NEW DUE_DATE AS SYDATE +7 .IF DUE_DATE GIVEN BY EMPLOYEE IS LESS THAN SYSDATE+7 THEN IT DOES NOT CHANGE THAT VALUE
CODE:---
_____________________________________________________________
create or replace
TRIGGER DDATE
BEFORE insert ON LOAN
FOR EACH ROW
BEGIN
-- Check for modification of title:
if :new.DUE_DATE > sysdate+7 then
:NEW.DUE_DATE := sysdate+7;
end if;
END;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.