Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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.

NLLABLE DATA DEFAULT | No No No No Yes No Yes No No COLUMN-ID COMMENTS 1 (null) 2 (null) 3 (null) 4 (null) 5 (null) 6 (null) 7 (null) 8 (null) 9 (null) COLUMN_NAME 1 LOAN ID 2 TOOL_NO 3 TOOL_DESC ID 4 EMPLOYEE ID 5 JOB ID 6 TOOL OUT DATE 7 DUE DATE 8 LOAN ACTIVE 9 LOAN STATUS CHANGE DATE DATE DATA TYPE NUMBER (8,0) NUMBER (8,0) NUMBER (8,0) NUMBER (8,0) NUMBER (8,0) DATE DATE VARCHAR2 (8 BYTE) (null) (null) (null) (null) (null) Sysdate (null) (null) Sysdate

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;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote