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

SQL Consider the CRETE TRIGGER command shown in the figure(lines 105 through 113

ID: 3705883 • Letter: S

Question

SQL

Consider the CRETE TRIGGER command shown in the figure(lines 105 through 113) Also remember that invoice_id is the primary key field for the invoices table being referred to here. What is the purpose of the trigger? 105 CREATE OR REPLACE TRIGGER invoices_before_insert 106 BEFORE INSERT ON invoices 107: FOR EACH ROW 108 WHEN (NEW.invoice_id IS NULL) 109 BEGIN 110 SELECT invoice id seg.NEXTVAL 111 INTO new.invoice_id 112 FROM dual 113 END 114 The trigger gets the last value in a sequence and uses the value to set the primary key value for the record being inserted The trigger prevents duplicate values from being inserted into the primary key field of the table The trigger gets the next value in a sequence and uses the value to set the primary key value for the record being inserted. The trigger prevents NULL values from being inserted into the primary key field of the table The trigger prevents an error being thrown for attempting to insert a NULL value into the primary key field

Explanation / Answer

ANSWER: According to this trigger option(C) and option(D) are correct because it is preventing to insert a primary key null and inserted a next value as primary key when null inserted.