You are on page 1of 4

Test: Quiz: Creating DDL and Database Event Triggers 1.

User HARJIT wants to prevent any objects which he owns from being dropp ed. Harjit decides to execute the following code: CREATE OR REPLACE TRIGGER stop_drop ---- Line A BEGIN RAISE_APPLICATION_ERROR(-20201,'Attempted drop'); END; What should Harjit code at Line A? Mark for Review (1) Points BEFORE DROP ON HARJIT BEFORE DROP ON TABLE BEFORE DROP ON SCHEMA (*) BEFORE DROP ON OWNER BEFORE DROP ON USER_OBJECTS

Correct 2. What is the benefit of using the CALL statement in a trigger body? Mark for Review (1) Points It allow both DDL events and database events to be handled by a single t rigger. It prevents data being read from a mutating table. It allows the database administrator to monitor who is currently connect ed to the database. It allows the trigger body code to be placed in a separate procedure. (* )

Correct 3. Which of the following could NOT cause a DDL or Database Event trigger to fire? Mark for Review (1) Points

A table is dropped. A user connects to the database. The DBA starts up the database. A user deletes rows from the EMPLOYEES table. (*) A specific exception is raised in a user's session.

Correct 4. The database administrator wants to write a log record every time any u ser's session raises an ORA-00942 exception. The DBA decides to create the follo wing trigger: CREATE OR REPLACE TRIGGER log_942_trigg AFTER SERVERERROR ON DATABASE BEGIN -- Line A INSERT INTO log_table VALUES ( ...); END; What should the DBA code at Line A? Mark for Review (1) Points IF (SERVERERROR(942)) THEN IF (IS_SERVERERROR(942)) THEN (*) IF (SERVERERROR = 942) THEN IF (IS_SERVERERROR = 942) THEN IF (IS_SERVERERROR(ORA-00942)) THEN

Correct 5. What is wrong with the following code? CREATE OR REPLACE TRIGGER call_trigg AFTER UPDATE OR DELETE ON employees BEGIN CALL del_emp_proc END; Mark for Review (1) Points

When CALL is used, the END; statement should be omitted. (*) The CALL statement should end with a semicolon (;) You cannot use a CALL statement in a DML trigger. When using CALL, only one DML statement can be tested, so UPDATE OR DELE TE is wrong.

Correct 6. What is wrong with the following code? CREATE OR REPLACE TRIGGER emp_dml_trigg BEFORE UPDATE OF salary ON employees FOR EACH ROW DECLARE v_max_sal employees.salary%TYPE; BEGIN SELECT max(sal) INTO v_max_sal FROM employees; END; Mark for Review (1) Points You cannot use a DECLARE statement in a trigger. The trigger body is reading the same table (employees) that the triggeri ng event is updating. (*) You must use RAISE_APPLICATION_ERROR in a BEFORE trigger. You can never use SELECT inside a DML trigger. Nothing is wrong, the trigger will execute correctly.

Correct 7. The database administrator creates a trigger that automatically disconn ects user HACKER whenever HACKER connects to the database. What type of trigger is this? Mark for Review (1) Points A DDL trigger

A Database Event trigger (*) A DML trigger A statement trigger An INSTEAD OF trigger

Correct 8. Mutating table errors can be caused by DML triggers, but not by databas e event triggers. True or False? Mark for Review (1) Points True (*) False

Correct 9. You can create a trigger which prevents DDL statements on an individual table, while still allowing DDL on other tables in the same schema. True or Fal se? Mark for Review (1) Points True False (*)

Correct 10. You have been granted CREATE TRIGGER privilege. You can now cre ate an AFTER LOGOFF ON SCHEMA trigger. True or False? Mark for Review (1) Points True False (*)

Correct

You might also like