You are on page 1of 3

Test: Quiz: Creating DML Triggers - Part 1 Bekijk uw antwoorden, feedback en scores hieronder.

Een asterisk (*) geeft een goed antwoord aan. Section 1 (Beantwoord alle vragen in deze sectie.) 1. An AFTER UPDATE trigger can specify more than one column. True or False? Markeren voor nakijken (1) Punten

Waar (*) Niet waar Correct 2. Which of the following are possible keywords for the timing component of a trigger? (Choose three.) (Kies alle goede antwoorden.) BEFORE (*) INSTEAD WHENEVER INSTEAD OF (*) AFTER (*) Correct 3. We want to create a log record automatically every time any DML operation is executed on either or both of the EMPLOYEES and DEPARTMENTS tables. What is the smallest number of triggers that must be create to do this? One Two (*) Three Six Eight Correct 4. 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, but not if a different column is updated. CREATE TRIGGER job_upd_trigg AFTER UPDATE ON employees(job_id) BEGIN ... CREATE TRIGGER job_upd_trigg WHENEVER UPDATE OF job_id IN employees BEGIN ... CREATE TRIGGER job_upd_trigg AFTER UPDATE ON employees.job_id BEGIN ... CREATE TRIGGER job_upd_trigg AFTER UPDATE OF job_id ON employees BEGIN ... (*) Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten

SYSDATE). (*) One Three Four None of the above Correct 7.Correct 5. There are five employees in department 50. COMMIT. How many times will the trigger fire. once after each row and once at the end of the statement The trigger will not fire at all Correct 8. A BEFORE statement trigger inserts a row into a logging table every time a user updates the salary column of the employees table. A DML trigger cannot itself contain a DML statement such as INSERT INTO audit_table You cannot use COMMIT inside a trigger. but the update fails because it violates a check constraint. after the DELETE is executed (*) Six times. The user now tries to update the salaries of three employees with a single UPDATE statement. after each employee row is deleted Once. We want to prevent employees from being deleted on Sundays.. the trigger will execute successfully Correct 6. (*) The last line of code should be END mytrigg. The second line should be: AFTER DELETE OF DEPARTMENTS Nothing is wrong. we create the following trigger: Markeren voor nakijken Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten .. END. before the DELETE is executed Five times. the transactions are rolled back because the update failed. 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. A statement trigger is created by: CREATE OR REPLACE TRIGGER emp_upd_trigg AFTER DELETE ON EMPLOYEES BEGIN . A user now executes: DELETE FROM employees WHERE department_id = 50. To do this. How many rows will be inserted into the logging table? None. and when? Once.

It should be an AFTER trigger because the Oracle Server cannot fire the trigger until it knows that the employee has been deleted. Correct . END IF.'DY') = 'SUN' THEN RAISE_APPLICATION_ERROR(-20101.... either a BEFORE or an AFTER trigger could be created. DELETE ON employees -. Should this be a BEFORE or AFTER trigger.Line A BEGIN IF TO_CHAR(SYSDATE'.(1) Punten CREATE OR REPLACE TRIGGER stop_del_emps . END. It does not matter.. and why? It should be a BEFORE trigger because if an AFTER trigger were created.'Invalid delete')... the employee would already have been deleted by the time the trigger checks the date. (*) It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggers.