Anda di halaman 1dari 4

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

Een asterisk (*) geeft een goed antwoord aan. Section 1 (Beantwoord alle vragen in deze sectie.) 1. The OLD and NEW qualifiers can be used with statement triggers as well as row triggers. True or False? Waar Niet waar (*) Correct 2. Whenever an employee's JOB_ID is updated, we want to insert a row into a logging table to record the employee_id and the new value of JOB_ID. We create a row trigger whose body includes the following code: BEGIN INSERT INTO logging_table (emp_id, job_id) VALUES -- Point A END; At point A, which of the following will insert the correct data into the logging table? (Choose two.) (Kies alle goede antwoorden.) (:OLD.employee_id, :OLD.job_id); (:OLD.employee_id, :NEW.job_id); (*) (:NEW.employee_id, :OLD.job_id); (:NEW.employee_id, :NEW.job_id); (*) (NEW.employee_id, NEW.job_id); Correct 3. A row trigger has been created which is fired by UPDATE ON employees. A user now executes a single SQL statement which updates four rows of the EMPLOYEES table. How many times will the row trigger fire? Once Twice Four times (*) Five times Eight times Correct 4. Examine the following code. To create a row trigger, what code should be included at Line A? CREATE OR REPLACE TRIGGER del_emp_trigg BEFORE DELETE ON employees ---- Line A BEGIN ... FOR EVERY ROW Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten

FOR EACH ROW (*) FOR EVERY ROW FOR ALL ROWS Nothing is needed because DML triggers are row triggers by default. Correct 5. The following view and trigger have been created: CREATE VIEW dept_view AS SELECT * FROM departments; CREATE OR REPLACE TRIGGER dept_view_trigg INSTEAD OF UPDATE ON dept_view BEGIN DBMS_OUTPUT.PUT_LINE('Sample Message'); END; Departments 50 and 80 exist but department 81 does not. A user now executes the following statement: UPDATE dept_view SET department_name = 'Sales' WHERE department_id IN (50,80,81); What happens? Two rows are updated and "Sample Message" is displayed once. No rows are updated and "Sample Message" is displayed once. No rows are updated and "Sample Message" is displayed twice. (*) No rows are updated and "Sample Message" is displayed three times. None of the above. Correct 6. What are the timing events for a compound trigger? Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten

Before the triggering statement; After the triggering statement; Instead of the triggering statement. Before the triggering statement; Before each row; After each row; After the triggering statement. (*) Before the triggering statement; After the triggering statement; After each row. Before the triggering statement; Before each row; After the triggering statement. Correct 7. What is wrong with this compound trigger example? CREATE OR REPLACE TRIGGER compound_trigger FOR UPDATE OF salary COMPOUND TRIGGER threshold CONSTANT SIMPLE_INTEGER := 200; BEFORE EACH ROW IS BEGIN -- some action END BEFORE EACH ROW; Markeren voor nakijken (1) Punten

AFTER EACH ROW IS BEGIN -- some action END AFTER EACH ROW; AFTER STATEMENT IS BEGIN -- some action END AFTER STATEMENT; END compound_trigger; Missing BEFORE timing statement. Missing the EXCEPTION section. Missing name of table on which the trigger fires. (*) Missing the INSTEAD OF timing section. Missing the BEFORE and INSTEAD OF timing sections. Correct 8. Which of the following best describes conditional predicates in a trigger? Markeren voor nakijken (1) Punten

They are special variables which must be DECLAREd within the trigger. They allow the trigger code to see what data values are being inserted into a row. They are automatically declared boolean variables which allow the trigger body to detect which DML operation is being executed. (*) They are special cursor attributes, like %ROWCOUNT and %NOTFOUND Correct 9. Which of the following statements about INSTEAD OF triggers are NOT true? (Choose two.) (Kies alle goede antwoorden.) They can be created on a table. (*) They can be created on a simple view. They can be created on a complex view. They can be statement triggers. (*) They can be row triggers. Correct 10. You decide to create the following trigger: CREATE OR REPLACE TRIGGER empl_trigg BEFORE UPDATE ON employees BEGIN -- Line A RAISE_APPLICATION_ERROR('Cannot update salary'); ELSE INSERT INTO log_table values (USER, SYSDATE); END IF; END; You want the trigger to prevent updates to the SALARY column, but allow Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten

updates to all other columns. What should you code at Line A? IF UPDATING SALARY THEN IF UPDATING('SALARY') THEN (*) IF UPDATE('SALARY') THEN IF UPDATING(SALARY) THEN IF UPDATE(SALARY) THEN Correct

Anda mungkin juga menyukai