You are on page 1of 4

Test: Quiz: Creating DML Triggers: Part I 1.

We want to create a log record automatically every time any DML operati on is executed on either or both of the EMPLOYEES and DEPARTMENTS tables. What i s the smallest number of triggers that must be create to do this? Mark for Review (1) Points One Two (*) Three Six Eight

Correct 2. Which of the following are possible keywords for the timing component o f a trigger? (Choose three.) Mark for Review (1) Points (Choose all correct answers) BEFORE (*) INSTEAD WHENEVER INSTEAD OF (*) AFTER (*)

Correct 3. What is wrong with the following code? CREATE OR REPLACE TRIGGER mytrigg AFTER DELETE ON departments BEGIN INSERT INTO audit_table (who, when) VALUES (USER, SYSDATE); COMMIT; END;

A BEFORE statement trigger inserts a row into a logging table every tim e a user updates the salary column of the employees table. (*) One Three Four None of the above Incorrect. How many rows will be inser ted into the logging table? Mark for Review (1) Points None. . the transactions are rolled back because the update failed. Mark for Review (1) Points CREATE TRIGGER job_upd_trigg AFTER UPDATE ON employees(job_id) BEGIN . but the update fails because it violates a check constraint. 5.Mark for Review (1) Points A DML trigger cannot itself contain a DML statement such as INSERT INTO audit_table You cannot use COMMIT inside a trigger. The second line should be: AFTER DELETE OF DEPARTMENTS Nothing is wrong. but not if a different column is updated. (*) The last line of code should be END mytrigg. Refer to Section 13 Lesson 2.. Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table? The trigger must fire whenever an employee 's JOB_ID is updated. the trigger will execute successfully Correct 4. The user now tries to update the salaries of three employees with a single UPDATE statement..

.. True or False ? Mark for Review (1) Points True (*) False Correct 7. A statement trigger is creat ed by: CREATE OR REPLACE TRIGGER emp_upd_trigg AFTER DELETE ON EMPLOYEES BEGIN .. CREATE TRIGGER job_upd_trigg AFTER UPDATE OF job_id ON employees BEGIN . once after each row and once at the end of the statement . An AFTER UPDATE trigger can specify more than one column.. There are five employees in department 50.job_id BEGIN . CREATE TRIGGER job_upd_trigg AFTER UPDATE ON employees. after the DELETE is executed (*) Six times. A user now executes: DELETE FROM employees WHERE department_id = 50.. How many times will the trigger fire.. and when? Mark for Review (1) Points Once. before the DELETE is executed Five times.CREATE TRIGGER job_upd_trigg WHENEVER UPDATE OF job_id IN employees BEGIN . after each employee row is deleted Once... (*) Correct 6.

It should be an AFTER trigger because the Oracle Server cannot fire the trigger until it knows that the employee has been deleted.. We want to prevent employees from being deleted on Sundays... It does not matter. DELETE ON employees -. END. Correct .Line A BEGIN IF TO_CHAR(SYSDATE'.The trigger will not fire at all Correct 8. (*) It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_E RROR with AFTER triggers. either a BEFORE or an AFTER trigger could be created .'Invalid delete').. and why? Mark for Review (1) Points It should be a BEFORE trigger because if an AFTER trigger were created. To do this..'DY') = 'SUN' THEN RAISE_APPLICATION_ERROR(-20101. the employee would already have been deleted by the time the trigger checks the date. Should this be a BEFORE or AFTER trigger.. we create the following trigger: CREATE OR REPLACE TRIGGER stop_del_emps . END IF.