10-13

37
1. Package Specification DEPT_PACK was created by the following code: CREATE OR REPLACE PACKAGE dept_pack IS PROCEDURE ins_dept(p_deptno IN NUMBER); FUNCTION get_dept(p_deptno IN NUMBER) RETURN VARCHAR2; END dept_pack; Which of the following are correct syntax for invoking the package subprograms? (Choose two.) Mark for Review (1) Points (Choose all correct answers) BEGIN dept_pack.ins_dept(20); END; (*) BEGIN dept_pack.get_dept(20); END; DECLARE v_deptname VARCHAR2(20); BEGIN v_deptname := get_dept(50); END; CREATE PROCEDURE dept_proc IS v_deptname VARCHAR2(20); BEGIN v_deptname := dept_pack.get_dept(40); END; (*) BEGIN dept_pack(30); END; Incorrect. Refer to Section 10 Lesson 1. 2. In which component of a package is the full definition of a public procedure written? Mark for Review (1) Points Body (*) Specification

description

oracle

Transcript of 10-13

Page 1: 10-13

1 Package Specification DEPT_PACK was created by the following codeCREATE OR REPLACE PACKAGE dept_pack ISPROCEDURE ins_dept(p_deptno IN NUMBER)FUNCTION get_dept(p_deptno IN NUMBER) RETURN VARCHAR2END dept_packWhich of the following are correct syntax for invoking the package subprograms(Choose two)Mark for Review(1) Points(Choose all correct answers)BEGINdept_packins_dept(20)END()BEGINdept_packget_dept(20)ENDDECLAREv_deptname VARCHAR2(20)BEGINv_deptname = get_dept(50)ENDCREATE PROCEDURE dept_proc ISv_deptname VARCHAR2(20)BEGINv_deptname = dept_packget_dept(40)END()BEGINdept_pack(30)ENDIncorrect Refer to Section 10 Lesson 12 In which component of a package is the full definitionof a public procedure written Mark for Review(1) PointsBody ()SpecificationBoth the body and the specificationNeither the body nor the specificationIncorrect Refer to Section 10 Lesson 13 Which of the following can be included in a packageMark for Review(1) Pointsprocedures

variablesPLSQL typesExceptionsAll of the above ()Correct4 Package EMP_PACK contains two procedures DEL_EMP and SHOW_EMP You want to write an anonymous block which invokes these procedures butyou have forgotten which parameters they use Which of the following will giveyou this information Mark for Review(1) PointsDESCRIBE del_empDESCRIBE show_empDESCRIBE emp_pack(del_emp show_emp)DESCRIBE emp_pack()DESCRIBE emp_packdel_empDESCRIBE emp_packshow_empNone of the aboveCorrect5 A number variable declared in a package is initializedto 0 unless assigned another value True or False Mark for Review(1) PointsTrueFalse ()Correct6 Which of the following are good reasons to group a setof procedures and functions into a package Mark for Review(1) PointsApplication developers do not need to know the details of the package body codeRelated subprograms and variables can be grouped together for easier management and maintenanceIf the detailed code is changed applications which invoke the package do not need to be recompiledAll of the above ()Incorrect Refer to Section 10 Lesson 17 To be able to invoke a package subprogram from outsidethe package it must be declared in the package Mark for Review(1) PointsBody

SpecificationBody and the specification ()None of the aboveIncorrect Refer to Section 10 Lesson 18 The two parts of a package are stored as separate objects in the database True or False Mark for Review(1) PointsTrue ()FalseCorrect1 What will be displayed when a user executes the following statementSELECT object_name FROM user_objectsWHERE object_type LIKE PACKMark for Review(1) PointsThe names of all package specifications in the users schemaThe names of all package specifications and package bodies in the usersschema ()The parameters which must be used when invoking all packaged subprogramsin the users schemaThe detailed code of all packages in the users schemaThe names of all packages which can be invoked by the userIncorrect Refer to Section 10 Lesson 22 SCOTTs schema contains a package EMP_PKG which contains a public procedure EMP_SAL which accepts a NUMBER parameter If the invoker has execute rights on the package which of the following will invoke the function successfully Mark for Review(1) Pointsemp_pkgemp_sal(101)scottemp_pkgemp_sal(101) ()emp_sal(101)None of the aboveAll of the aboveIncorrect Refer to Section 10 Lesson 23 A public component declared in the package specification can be referenced by a private component defined in the package body True orFalse Mark for Review(1) PointsTrue ()False

Correct4 We want to remove both the specification and the body of package CO_PACK from the database Which of the following commands will do this Mark for Review(1) PointsDROP BOTH co_packDROP PACKAGE BODY co_packDROP PACKAGE co_pack ()DROP PACKAGE SPECIFICATION co_packNone of the aboveIncorrect Refer to Section 10 Lesson 25 A local variable defined inside a package procedure is visible to the calling environment True or False Mark for Review(1) PointsTrueFalse ()Correct6 Examine the following package specificationCREATE OR REPLACE PACKAGE mypack ISpercent_tax NUMBER = 20PROCEDURE proc1END mypackThe package body of mypack also includes a function called func1 Which of the following statements are true (Choose three)Mark for Review(1) Points(Choose all correct answers)proc1 is a public procedure and func1 is a private function()The package will not compile because you cannot declare variables in thespecification only procedures and functions The variable can be modified byBEGINmypackpercent_tax = 10END()The function can be invoked from outside the packageThe procedure can be invoked byBEGINmypackproc1END()

Incorrect Refer to Section 10 Lesson 27 Which one of the following queries would you use to seethe detailed code of a package called EMP_PKG Mark for Review(1) PointsSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT source FROM user_packages WHERE name = EMP_PKG AND type = PACKAGE BODY ORDER BY lineSELECT text FROM all_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEBODY ORDER BY line ()Incorrect Refer to Section 10 Lesson 28 Your schema contains a package called EMP_PKG You wantto remove the package body but not the specification The correct syntax to dothis is DROP BODY emp_pkg True or False Mark for Review(1) PointsTrueFalse ()Correct9 A local variable declared within a procedure in a package can be referenced by any other component of that package True or FalseMark for Review(1) PointsTrueFalse ()Correct10 When one component of a package is called all the packages components are loaded into memory True or False Mark for Review(1) PointsTrue ()FalseCorrect1 The package name must be included when calling a packagefunction from a SELECT statement executed outside the package True or FalseMark for Review(1) PointsTrue ()

FalseIncorrect Refer to Section 10 Lesson 32 Examine the following package codeCREATE OR REPLACE PACKAGE over_pack ISPROCEDURE do_work1 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work2 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work1 (param1 IN CHAR param2 IN NUMBER)FUNCTION do_work2 (param1 IN VARCHAR2 param2 IN NUMBER) RETURN DATEEND over_packWhich of the following calls will be successful (Choose three)Mark for Review(1) Points(Choose all correct answers)over_packdo_work1(Smith20)v_date = over_packdo_work2(Smith20) ()over_packdo_work2(Smith20) ()over_packdo_work1(p1=gtSmithp2=gt20) ()over_packdo_work1(param1=gtSmith)Incorrect Refer to Section 10 Lesson 33 A package initialization block is executed automatically every time a user invokes any procedure or function in the package True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 10 Lesson 34 How would you invoke the constant km_to_mile from the global_consts bodiless package at VARIABLE ASELECT trail_name distance_in_km VARIABLE AFROM trailsWHERE park_name = YOSEMITEMark for Review(1) Pointskm_to_mileglobal_constskm_to_mile (global_consts)global_constskm_to_mile ()global_consts (km_to_mile)Incorrect Refer to Section 10 Lesson 35 The following package is valid True or FalseCREATE OR REPLACE PACKAGE exceptions_pkg ISe_cons_violation EXCEPTIONPRAGMA EXCEPTION_INIT (e_cons_violation -2292)e_value_too_large EXCEPTIONPRAGMA EXCEPTION_INIT (e_value_too_large -1438)

END exceptions_pkgMark for Review(1) PointsTrue ()FalseCorrect6 The following example package specification is valid tocreate a data type ed_type that can be used in other subprograms True or FalseCREATE OR REPLACE PACKAGE emp_dept_pkgISTYPE ed_type IS RECORD (f_name employeesfirst_nameTYPEl_name employeeslast_nameTYPEd_name departmentsdepartment_nameTYPE)PROCEDURE sel_emp_dept(p_emp_id IN employeesemployee_idTYPEp_emp_dept_rec OUT ed_type)END emp_dept_pkgMark for Review(1) PointsTrue ()FalseCorrect7 Which of the following best describes a package initialization block Mark for Review(1) PointsIt is a named procedure in a package which must be invoked by a user before any other part of the package can be invokedIt is an anonymous block in the package specificationIt is an anonymous block at the end of a package body which executes automatically the first time each user session invokes a subprogram in the package()It is a private function within the package bodyBecause it is an anonymous block it cannot be invoked and therefore will never execute It is treated as a set of commentsIncorrect Refer to Section 10 Lesson 38 Package FORWARD_PACK contains two procedures PROC1 ispublic while PROC2 is private (not declared in the package specification) Theseprocedures have no parameters Which of the following package bodies will NOT compile successfully (Choose two) Mark for Review

(1) Points(Choose all correct answers)CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDPROCEDURE proc1 ISBEGINproc2ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISproc1ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack IS

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 2: 10-13

variablesPLSQL typesExceptionsAll of the above ()Correct4 Package EMP_PACK contains two procedures DEL_EMP and SHOW_EMP You want to write an anonymous block which invokes these procedures butyou have forgotten which parameters they use Which of the following will giveyou this information Mark for Review(1) PointsDESCRIBE del_empDESCRIBE show_empDESCRIBE emp_pack(del_emp show_emp)DESCRIBE emp_pack()DESCRIBE emp_packdel_empDESCRIBE emp_packshow_empNone of the aboveCorrect5 A number variable declared in a package is initializedto 0 unless assigned another value True or False Mark for Review(1) PointsTrueFalse ()Correct6 Which of the following are good reasons to group a setof procedures and functions into a package Mark for Review(1) PointsApplication developers do not need to know the details of the package body codeRelated subprograms and variables can be grouped together for easier management and maintenanceIf the detailed code is changed applications which invoke the package do not need to be recompiledAll of the above ()Incorrect Refer to Section 10 Lesson 17 To be able to invoke a package subprogram from outsidethe package it must be declared in the package Mark for Review(1) PointsBody

SpecificationBody and the specification ()None of the aboveIncorrect Refer to Section 10 Lesson 18 The two parts of a package are stored as separate objects in the database True or False Mark for Review(1) PointsTrue ()FalseCorrect1 What will be displayed when a user executes the following statementSELECT object_name FROM user_objectsWHERE object_type LIKE PACKMark for Review(1) PointsThe names of all package specifications in the users schemaThe names of all package specifications and package bodies in the usersschema ()The parameters which must be used when invoking all packaged subprogramsin the users schemaThe detailed code of all packages in the users schemaThe names of all packages which can be invoked by the userIncorrect Refer to Section 10 Lesson 22 SCOTTs schema contains a package EMP_PKG which contains a public procedure EMP_SAL which accepts a NUMBER parameter If the invoker has execute rights on the package which of the following will invoke the function successfully Mark for Review(1) Pointsemp_pkgemp_sal(101)scottemp_pkgemp_sal(101) ()emp_sal(101)None of the aboveAll of the aboveIncorrect Refer to Section 10 Lesson 23 A public component declared in the package specification can be referenced by a private component defined in the package body True orFalse Mark for Review(1) PointsTrue ()False

Correct4 We want to remove both the specification and the body of package CO_PACK from the database Which of the following commands will do this Mark for Review(1) PointsDROP BOTH co_packDROP PACKAGE BODY co_packDROP PACKAGE co_pack ()DROP PACKAGE SPECIFICATION co_packNone of the aboveIncorrect Refer to Section 10 Lesson 25 A local variable defined inside a package procedure is visible to the calling environment True or False Mark for Review(1) PointsTrueFalse ()Correct6 Examine the following package specificationCREATE OR REPLACE PACKAGE mypack ISpercent_tax NUMBER = 20PROCEDURE proc1END mypackThe package body of mypack also includes a function called func1 Which of the following statements are true (Choose three)Mark for Review(1) Points(Choose all correct answers)proc1 is a public procedure and func1 is a private function()The package will not compile because you cannot declare variables in thespecification only procedures and functions The variable can be modified byBEGINmypackpercent_tax = 10END()The function can be invoked from outside the packageThe procedure can be invoked byBEGINmypackproc1END()

Incorrect Refer to Section 10 Lesson 27 Which one of the following queries would you use to seethe detailed code of a package called EMP_PKG Mark for Review(1) PointsSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT source FROM user_packages WHERE name = EMP_PKG AND type = PACKAGE BODY ORDER BY lineSELECT text FROM all_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEBODY ORDER BY line ()Incorrect Refer to Section 10 Lesson 28 Your schema contains a package called EMP_PKG You wantto remove the package body but not the specification The correct syntax to dothis is DROP BODY emp_pkg True or False Mark for Review(1) PointsTrueFalse ()Correct9 A local variable declared within a procedure in a package can be referenced by any other component of that package True or FalseMark for Review(1) PointsTrueFalse ()Correct10 When one component of a package is called all the packages components are loaded into memory True or False Mark for Review(1) PointsTrue ()FalseCorrect1 The package name must be included when calling a packagefunction from a SELECT statement executed outside the package True or FalseMark for Review(1) PointsTrue ()

FalseIncorrect Refer to Section 10 Lesson 32 Examine the following package codeCREATE OR REPLACE PACKAGE over_pack ISPROCEDURE do_work1 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work2 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work1 (param1 IN CHAR param2 IN NUMBER)FUNCTION do_work2 (param1 IN VARCHAR2 param2 IN NUMBER) RETURN DATEEND over_packWhich of the following calls will be successful (Choose three)Mark for Review(1) Points(Choose all correct answers)over_packdo_work1(Smith20)v_date = over_packdo_work2(Smith20) ()over_packdo_work2(Smith20) ()over_packdo_work1(p1=gtSmithp2=gt20) ()over_packdo_work1(param1=gtSmith)Incorrect Refer to Section 10 Lesson 33 A package initialization block is executed automatically every time a user invokes any procedure or function in the package True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 10 Lesson 34 How would you invoke the constant km_to_mile from the global_consts bodiless package at VARIABLE ASELECT trail_name distance_in_km VARIABLE AFROM trailsWHERE park_name = YOSEMITEMark for Review(1) Pointskm_to_mileglobal_constskm_to_mile (global_consts)global_constskm_to_mile ()global_consts (km_to_mile)Incorrect Refer to Section 10 Lesson 35 The following package is valid True or FalseCREATE OR REPLACE PACKAGE exceptions_pkg ISe_cons_violation EXCEPTIONPRAGMA EXCEPTION_INIT (e_cons_violation -2292)e_value_too_large EXCEPTIONPRAGMA EXCEPTION_INIT (e_value_too_large -1438)

END exceptions_pkgMark for Review(1) PointsTrue ()FalseCorrect6 The following example package specification is valid tocreate a data type ed_type that can be used in other subprograms True or FalseCREATE OR REPLACE PACKAGE emp_dept_pkgISTYPE ed_type IS RECORD (f_name employeesfirst_nameTYPEl_name employeeslast_nameTYPEd_name departmentsdepartment_nameTYPE)PROCEDURE sel_emp_dept(p_emp_id IN employeesemployee_idTYPEp_emp_dept_rec OUT ed_type)END emp_dept_pkgMark for Review(1) PointsTrue ()FalseCorrect7 Which of the following best describes a package initialization block Mark for Review(1) PointsIt is a named procedure in a package which must be invoked by a user before any other part of the package can be invokedIt is an anonymous block in the package specificationIt is an anonymous block at the end of a package body which executes automatically the first time each user session invokes a subprogram in the package()It is a private function within the package bodyBecause it is an anonymous block it cannot be invoked and therefore will never execute It is treated as a set of commentsIncorrect Refer to Section 10 Lesson 38 Package FORWARD_PACK contains two procedures PROC1 ispublic while PROC2 is private (not declared in the package specification) Theseprocedures have no parameters Which of the following package bodies will NOT compile successfully (Choose two) Mark for Review

(1) Points(Choose all correct answers)CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDPROCEDURE proc1 ISBEGINproc2ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISproc1ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack IS

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 3: 10-13

SpecificationBody and the specification ()None of the aboveIncorrect Refer to Section 10 Lesson 18 The two parts of a package are stored as separate objects in the database True or False Mark for Review(1) PointsTrue ()FalseCorrect1 What will be displayed when a user executes the following statementSELECT object_name FROM user_objectsWHERE object_type LIKE PACKMark for Review(1) PointsThe names of all package specifications in the users schemaThe names of all package specifications and package bodies in the usersschema ()The parameters which must be used when invoking all packaged subprogramsin the users schemaThe detailed code of all packages in the users schemaThe names of all packages which can be invoked by the userIncorrect Refer to Section 10 Lesson 22 SCOTTs schema contains a package EMP_PKG which contains a public procedure EMP_SAL which accepts a NUMBER parameter If the invoker has execute rights on the package which of the following will invoke the function successfully Mark for Review(1) Pointsemp_pkgemp_sal(101)scottemp_pkgemp_sal(101) ()emp_sal(101)None of the aboveAll of the aboveIncorrect Refer to Section 10 Lesson 23 A public component declared in the package specification can be referenced by a private component defined in the package body True orFalse Mark for Review(1) PointsTrue ()False

Correct4 We want to remove both the specification and the body of package CO_PACK from the database Which of the following commands will do this Mark for Review(1) PointsDROP BOTH co_packDROP PACKAGE BODY co_packDROP PACKAGE co_pack ()DROP PACKAGE SPECIFICATION co_packNone of the aboveIncorrect Refer to Section 10 Lesson 25 A local variable defined inside a package procedure is visible to the calling environment True or False Mark for Review(1) PointsTrueFalse ()Correct6 Examine the following package specificationCREATE OR REPLACE PACKAGE mypack ISpercent_tax NUMBER = 20PROCEDURE proc1END mypackThe package body of mypack also includes a function called func1 Which of the following statements are true (Choose three)Mark for Review(1) Points(Choose all correct answers)proc1 is a public procedure and func1 is a private function()The package will not compile because you cannot declare variables in thespecification only procedures and functions The variable can be modified byBEGINmypackpercent_tax = 10END()The function can be invoked from outside the packageThe procedure can be invoked byBEGINmypackproc1END()

Incorrect Refer to Section 10 Lesson 27 Which one of the following queries would you use to seethe detailed code of a package called EMP_PKG Mark for Review(1) PointsSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT source FROM user_packages WHERE name = EMP_PKG AND type = PACKAGE BODY ORDER BY lineSELECT text FROM all_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEBODY ORDER BY line ()Incorrect Refer to Section 10 Lesson 28 Your schema contains a package called EMP_PKG You wantto remove the package body but not the specification The correct syntax to dothis is DROP BODY emp_pkg True or False Mark for Review(1) PointsTrueFalse ()Correct9 A local variable declared within a procedure in a package can be referenced by any other component of that package True or FalseMark for Review(1) PointsTrueFalse ()Correct10 When one component of a package is called all the packages components are loaded into memory True or False Mark for Review(1) PointsTrue ()FalseCorrect1 The package name must be included when calling a packagefunction from a SELECT statement executed outside the package True or FalseMark for Review(1) PointsTrue ()

FalseIncorrect Refer to Section 10 Lesson 32 Examine the following package codeCREATE OR REPLACE PACKAGE over_pack ISPROCEDURE do_work1 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work2 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work1 (param1 IN CHAR param2 IN NUMBER)FUNCTION do_work2 (param1 IN VARCHAR2 param2 IN NUMBER) RETURN DATEEND over_packWhich of the following calls will be successful (Choose three)Mark for Review(1) Points(Choose all correct answers)over_packdo_work1(Smith20)v_date = over_packdo_work2(Smith20) ()over_packdo_work2(Smith20) ()over_packdo_work1(p1=gtSmithp2=gt20) ()over_packdo_work1(param1=gtSmith)Incorrect Refer to Section 10 Lesson 33 A package initialization block is executed automatically every time a user invokes any procedure or function in the package True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 10 Lesson 34 How would you invoke the constant km_to_mile from the global_consts bodiless package at VARIABLE ASELECT trail_name distance_in_km VARIABLE AFROM trailsWHERE park_name = YOSEMITEMark for Review(1) Pointskm_to_mileglobal_constskm_to_mile (global_consts)global_constskm_to_mile ()global_consts (km_to_mile)Incorrect Refer to Section 10 Lesson 35 The following package is valid True or FalseCREATE OR REPLACE PACKAGE exceptions_pkg ISe_cons_violation EXCEPTIONPRAGMA EXCEPTION_INIT (e_cons_violation -2292)e_value_too_large EXCEPTIONPRAGMA EXCEPTION_INIT (e_value_too_large -1438)

END exceptions_pkgMark for Review(1) PointsTrue ()FalseCorrect6 The following example package specification is valid tocreate a data type ed_type that can be used in other subprograms True or FalseCREATE OR REPLACE PACKAGE emp_dept_pkgISTYPE ed_type IS RECORD (f_name employeesfirst_nameTYPEl_name employeeslast_nameTYPEd_name departmentsdepartment_nameTYPE)PROCEDURE sel_emp_dept(p_emp_id IN employeesemployee_idTYPEp_emp_dept_rec OUT ed_type)END emp_dept_pkgMark for Review(1) PointsTrue ()FalseCorrect7 Which of the following best describes a package initialization block Mark for Review(1) PointsIt is a named procedure in a package which must be invoked by a user before any other part of the package can be invokedIt is an anonymous block in the package specificationIt is an anonymous block at the end of a package body which executes automatically the first time each user session invokes a subprogram in the package()It is a private function within the package bodyBecause it is an anonymous block it cannot be invoked and therefore will never execute It is treated as a set of commentsIncorrect Refer to Section 10 Lesson 38 Package FORWARD_PACK contains two procedures PROC1 ispublic while PROC2 is private (not declared in the package specification) Theseprocedures have no parameters Which of the following package bodies will NOT compile successfully (Choose two) Mark for Review

(1) Points(Choose all correct answers)CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDPROCEDURE proc1 ISBEGINproc2ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISproc1ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack IS

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 4: 10-13

Correct4 We want to remove both the specification and the body of package CO_PACK from the database Which of the following commands will do this Mark for Review(1) PointsDROP BOTH co_packDROP PACKAGE BODY co_packDROP PACKAGE co_pack ()DROP PACKAGE SPECIFICATION co_packNone of the aboveIncorrect Refer to Section 10 Lesson 25 A local variable defined inside a package procedure is visible to the calling environment True or False Mark for Review(1) PointsTrueFalse ()Correct6 Examine the following package specificationCREATE OR REPLACE PACKAGE mypack ISpercent_tax NUMBER = 20PROCEDURE proc1END mypackThe package body of mypack also includes a function called func1 Which of the following statements are true (Choose three)Mark for Review(1) Points(Choose all correct answers)proc1 is a public procedure and func1 is a private function()The package will not compile because you cannot declare variables in thespecification only procedures and functions The variable can be modified byBEGINmypackpercent_tax = 10END()The function can be invoked from outside the packageThe procedure can be invoked byBEGINmypackproc1END()

Incorrect Refer to Section 10 Lesson 27 Which one of the following queries would you use to seethe detailed code of a package called EMP_PKG Mark for Review(1) PointsSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT source FROM user_packages WHERE name = EMP_PKG AND type = PACKAGE BODY ORDER BY lineSELECT text FROM all_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEBODY ORDER BY line ()Incorrect Refer to Section 10 Lesson 28 Your schema contains a package called EMP_PKG You wantto remove the package body but not the specification The correct syntax to dothis is DROP BODY emp_pkg True or False Mark for Review(1) PointsTrueFalse ()Correct9 A local variable declared within a procedure in a package can be referenced by any other component of that package True or FalseMark for Review(1) PointsTrueFalse ()Correct10 When one component of a package is called all the packages components are loaded into memory True or False Mark for Review(1) PointsTrue ()FalseCorrect1 The package name must be included when calling a packagefunction from a SELECT statement executed outside the package True or FalseMark for Review(1) PointsTrue ()

FalseIncorrect Refer to Section 10 Lesson 32 Examine the following package codeCREATE OR REPLACE PACKAGE over_pack ISPROCEDURE do_work1 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work2 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work1 (param1 IN CHAR param2 IN NUMBER)FUNCTION do_work2 (param1 IN VARCHAR2 param2 IN NUMBER) RETURN DATEEND over_packWhich of the following calls will be successful (Choose three)Mark for Review(1) Points(Choose all correct answers)over_packdo_work1(Smith20)v_date = over_packdo_work2(Smith20) ()over_packdo_work2(Smith20) ()over_packdo_work1(p1=gtSmithp2=gt20) ()over_packdo_work1(param1=gtSmith)Incorrect Refer to Section 10 Lesson 33 A package initialization block is executed automatically every time a user invokes any procedure or function in the package True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 10 Lesson 34 How would you invoke the constant km_to_mile from the global_consts bodiless package at VARIABLE ASELECT trail_name distance_in_km VARIABLE AFROM trailsWHERE park_name = YOSEMITEMark for Review(1) Pointskm_to_mileglobal_constskm_to_mile (global_consts)global_constskm_to_mile ()global_consts (km_to_mile)Incorrect Refer to Section 10 Lesson 35 The following package is valid True or FalseCREATE OR REPLACE PACKAGE exceptions_pkg ISe_cons_violation EXCEPTIONPRAGMA EXCEPTION_INIT (e_cons_violation -2292)e_value_too_large EXCEPTIONPRAGMA EXCEPTION_INIT (e_value_too_large -1438)

END exceptions_pkgMark for Review(1) PointsTrue ()FalseCorrect6 The following example package specification is valid tocreate a data type ed_type that can be used in other subprograms True or FalseCREATE OR REPLACE PACKAGE emp_dept_pkgISTYPE ed_type IS RECORD (f_name employeesfirst_nameTYPEl_name employeeslast_nameTYPEd_name departmentsdepartment_nameTYPE)PROCEDURE sel_emp_dept(p_emp_id IN employeesemployee_idTYPEp_emp_dept_rec OUT ed_type)END emp_dept_pkgMark for Review(1) PointsTrue ()FalseCorrect7 Which of the following best describes a package initialization block Mark for Review(1) PointsIt is a named procedure in a package which must be invoked by a user before any other part of the package can be invokedIt is an anonymous block in the package specificationIt is an anonymous block at the end of a package body which executes automatically the first time each user session invokes a subprogram in the package()It is a private function within the package bodyBecause it is an anonymous block it cannot be invoked and therefore will never execute It is treated as a set of commentsIncorrect Refer to Section 10 Lesson 38 Package FORWARD_PACK contains two procedures PROC1 ispublic while PROC2 is private (not declared in the package specification) Theseprocedures have no parameters Which of the following package bodies will NOT compile successfully (Choose two) Mark for Review

(1) Points(Choose all correct answers)CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDPROCEDURE proc1 ISBEGINproc2ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISproc1ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack IS

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 5: 10-13

Incorrect Refer to Section 10 Lesson 27 Which one of the following queries would you use to seethe detailed code of a package called EMP_PKG Mark for Review(1) PointsSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT source FROM user_packages WHERE name = EMP_PKG AND type = PACKAGE BODY ORDER BY lineSELECT text FROM all_source WHERE name = EMP_PKG AND type = PACKAGEORDER BY lineSELECT text FROM user_source WHERE name = EMP_PKG AND type = PACKAGEBODY ORDER BY line ()Incorrect Refer to Section 10 Lesson 28 Your schema contains a package called EMP_PKG You wantto remove the package body but not the specification The correct syntax to dothis is DROP BODY emp_pkg True or False Mark for Review(1) PointsTrueFalse ()Correct9 A local variable declared within a procedure in a package can be referenced by any other component of that package True or FalseMark for Review(1) PointsTrueFalse ()Correct10 When one component of a package is called all the packages components are loaded into memory True or False Mark for Review(1) PointsTrue ()FalseCorrect1 The package name must be included when calling a packagefunction from a SELECT statement executed outside the package True or FalseMark for Review(1) PointsTrue ()

FalseIncorrect Refer to Section 10 Lesson 32 Examine the following package codeCREATE OR REPLACE PACKAGE over_pack ISPROCEDURE do_work1 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work2 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work1 (param1 IN CHAR param2 IN NUMBER)FUNCTION do_work2 (param1 IN VARCHAR2 param2 IN NUMBER) RETURN DATEEND over_packWhich of the following calls will be successful (Choose three)Mark for Review(1) Points(Choose all correct answers)over_packdo_work1(Smith20)v_date = over_packdo_work2(Smith20) ()over_packdo_work2(Smith20) ()over_packdo_work1(p1=gtSmithp2=gt20) ()over_packdo_work1(param1=gtSmith)Incorrect Refer to Section 10 Lesson 33 A package initialization block is executed automatically every time a user invokes any procedure or function in the package True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 10 Lesson 34 How would you invoke the constant km_to_mile from the global_consts bodiless package at VARIABLE ASELECT trail_name distance_in_km VARIABLE AFROM trailsWHERE park_name = YOSEMITEMark for Review(1) Pointskm_to_mileglobal_constskm_to_mile (global_consts)global_constskm_to_mile ()global_consts (km_to_mile)Incorrect Refer to Section 10 Lesson 35 The following package is valid True or FalseCREATE OR REPLACE PACKAGE exceptions_pkg ISe_cons_violation EXCEPTIONPRAGMA EXCEPTION_INIT (e_cons_violation -2292)e_value_too_large EXCEPTIONPRAGMA EXCEPTION_INIT (e_value_too_large -1438)

END exceptions_pkgMark for Review(1) PointsTrue ()FalseCorrect6 The following example package specification is valid tocreate a data type ed_type that can be used in other subprograms True or FalseCREATE OR REPLACE PACKAGE emp_dept_pkgISTYPE ed_type IS RECORD (f_name employeesfirst_nameTYPEl_name employeeslast_nameTYPEd_name departmentsdepartment_nameTYPE)PROCEDURE sel_emp_dept(p_emp_id IN employeesemployee_idTYPEp_emp_dept_rec OUT ed_type)END emp_dept_pkgMark for Review(1) PointsTrue ()FalseCorrect7 Which of the following best describes a package initialization block Mark for Review(1) PointsIt is a named procedure in a package which must be invoked by a user before any other part of the package can be invokedIt is an anonymous block in the package specificationIt is an anonymous block at the end of a package body which executes automatically the first time each user session invokes a subprogram in the package()It is a private function within the package bodyBecause it is an anonymous block it cannot be invoked and therefore will never execute It is treated as a set of commentsIncorrect Refer to Section 10 Lesson 38 Package FORWARD_PACK contains two procedures PROC1 ispublic while PROC2 is private (not declared in the package specification) Theseprocedures have no parameters Which of the following package bodies will NOT compile successfully (Choose two) Mark for Review

(1) Points(Choose all correct answers)CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDPROCEDURE proc1 ISBEGINproc2ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISproc1ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack IS

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 6: 10-13

FalseIncorrect Refer to Section 10 Lesson 32 Examine the following package codeCREATE OR REPLACE PACKAGE over_pack ISPROCEDURE do_work1 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work2 (p1 IN VARCHAR2 p2 IN NUMBER)PROCEDURE do_work1 (param1 IN CHAR param2 IN NUMBER)FUNCTION do_work2 (param1 IN VARCHAR2 param2 IN NUMBER) RETURN DATEEND over_packWhich of the following calls will be successful (Choose three)Mark for Review(1) Points(Choose all correct answers)over_packdo_work1(Smith20)v_date = over_packdo_work2(Smith20) ()over_packdo_work2(Smith20) ()over_packdo_work1(p1=gtSmithp2=gt20) ()over_packdo_work1(param1=gtSmith)Incorrect Refer to Section 10 Lesson 33 A package initialization block is executed automatically every time a user invokes any procedure or function in the package True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 10 Lesson 34 How would you invoke the constant km_to_mile from the global_consts bodiless package at VARIABLE ASELECT trail_name distance_in_km VARIABLE AFROM trailsWHERE park_name = YOSEMITEMark for Review(1) Pointskm_to_mileglobal_constskm_to_mile (global_consts)global_constskm_to_mile ()global_consts (km_to_mile)Incorrect Refer to Section 10 Lesson 35 The following package is valid True or FalseCREATE OR REPLACE PACKAGE exceptions_pkg ISe_cons_violation EXCEPTIONPRAGMA EXCEPTION_INIT (e_cons_violation -2292)e_value_too_large EXCEPTIONPRAGMA EXCEPTION_INIT (e_value_too_large -1438)

END exceptions_pkgMark for Review(1) PointsTrue ()FalseCorrect6 The following example package specification is valid tocreate a data type ed_type that can be used in other subprograms True or FalseCREATE OR REPLACE PACKAGE emp_dept_pkgISTYPE ed_type IS RECORD (f_name employeesfirst_nameTYPEl_name employeeslast_nameTYPEd_name departmentsdepartment_nameTYPE)PROCEDURE sel_emp_dept(p_emp_id IN employeesemployee_idTYPEp_emp_dept_rec OUT ed_type)END emp_dept_pkgMark for Review(1) PointsTrue ()FalseCorrect7 Which of the following best describes a package initialization block Mark for Review(1) PointsIt is a named procedure in a package which must be invoked by a user before any other part of the package can be invokedIt is an anonymous block in the package specificationIt is an anonymous block at the end of a package body which executes automatically the first time each user session invokes a subprogram in the package()It is a private function within the package bodyBecause it is an anonymous block it cannot be invoked and therefore will never execute It is treated as a set of commentsIncorrect Refer to Section 10 Lesson 38 Package FORWARD_PACK contains two procedures PROC1 ispublic while PROC2 is private (not declared in the package specification) Theseprocedures have no parameters Which of the following package bodies will NOT compile successfully (Choose two) Mark for Review

(1) Points(Choose all correct answers)CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDPROCEDURE proc1 ISBEGINproc2ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISproc1ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack IS

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 7: 10-13

END exceptions_pkgMark for Review(1) PointsTrue ()FalseCorrect6 The following example package specification is valid tocreate a data type ed_type that can be used in other subprograms True or FalseCREATE OR REPLACE PACKAGE emp_dept_pkgISTYPE ed_type IS RECORD (f_name employeesfirst_nameTYPEl_name employeeslast_nameTYPEd_name departmentsdepartment_nameTYPE)PROCEDURE sel_emp_dept(p_emp_id IN employeesemployee_idTYPEp_emp_dept_rec OUT ed_type)END emp_dept_pkgMark for Review(1) PointsTrue ()FalseCorrect7 Which of the following best describes a package initialization block Mark for Review(1) PointsIt is a named procedure in a package which must be invoked by a user before any other part of the package can be invokedIt is an anonymous block in the package specificationIt is an anonymous block at the end of a package body which executes automatically the first time each user session invokes a subprogram in the package()It is a private function within the package bodyBecause it is an anonymous block it cannot be invoked and therefore will never execute It is treated as a set of commentsIncorrect Refer to Section 10 Lesson 38 Package FORWARD_PACK contains two procedures PROC1 ispublic while PROC2 is private (not declared in the package specification) Theseprocedures have no parameters Which of the following package bodies will NOT compile successfully (Choose two) Mark for Review

(1) Points(Choose all correct answers)CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDPROCEDURE proc1 ISBEGINproc2ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISproc1ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack IS

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 8: 10-13

(1) Points(Choose all correct answers)CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDPROCEDURE proc1 ISBEGINproc2ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINDBMS_OUTPUTPUT_LINE(Any message)ENDEND forward_packCREATE OR REPLACE PACKAGE BODY forward_pack ISPROCEDURE proc1PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISproc1ENDEND forward_pack()CREATE OR REPLACE PACKAGE BODY forward_pack IS

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 9: 10-13

PROCEDURE proc2PROCEDURE proc1 ISBEGINproc2ENDPROCEDURE proc2 ISBEGINproc1ENDEND forward_packIncorrect Refer to Section 10 Lesson 39 A bodiless package contains what Mark for Review(1) PointsProcedures onlyFunctions onlyPublic variables only ()Private variables onlyIncorrect Refer to Section 10 Lesson 310 If a subprogram is public (declared in the package specification) its detailed code can be written anywhere in the package body without the need to use forward declarations True or False Mark for Review(1) PointsTrue ()FalseCorrect11 INDEX BY is missing from this package declaration Select the most efficient declarationCREATE OR REPLACE PACKAGE emp_pkg ISTYPE emp_tab IS TABLE OF employeesROWTYPEPROCEDURE get_employees(p_emp_table OUT emp_tab)END emp_pkgMark for Review(1) PointsINDEX BY INTEGERINDEX BY BINARYINDEX BY BINARY_INTEGER ()INDEX ALLIncorrect Refer to Section 10 Lesson 312 Which one of the following is NOT a restriction on a package function called from a SQL statement Mark for Review(1) PointsThe function can include a COMMITThe function can be overloaded ()The function can include a ROLLBACK

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 10: 10-13

The function can return a BOOLEANIncorrect Refer to Section 10 Lesson 313 When using a package function in DML statements whichrules must you follow (Choose three) Mark for Review(1) Points(Choose all correct answers)Must not end the current transaction ()Can read or modify the table being changed by that DML statementChanges to a package variable could have an impact on another stored function ()Cannot execute a DML statement or modify the database ()Incorrect Refer to Section 10 Lesson 314 Which two of these functions could not be in the same package1 FUNCTION get_emp (p1 DATE) RETURN VARCHAR22 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN VARCHAR23 FUNCTION get_emp (p1 DATE p2 NUMBER) RETURN NUMBER4 FUNCTION get_emp (p1 NUMBER p2 DATE) RETURN VARCHAR2Mark for Review(1) Points1 and 21 and 42 and 42 and 3 ()3 and 4Incorrect Refer to Section 10 Lesson 31 In the following example which statement best fits in Line 1 (Choose 1)DECLAREv_more_rows_exist BOOLEAN = TRUEBEGIN-- Line 1LOOPv_more_rows_exist = curs_pkgfetch_n_rows(3)DBMS_OUTPUTPUT_LINE(-------)EXIT WHEN NOT v_more_rows_existEND LOOPcurs_pkgclose_cursENDMark for Review(1) Pointscurs_pkgemp_cursISOPENcurs_pkgclose_curscurs_pkgopen_curs ()EXIT WHEN curs_pkgemp_cursNOTFOUND

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 11: 10-13

Incorrect Refer to Section 11 Lesson 12 A packages state is initialized when the package is first loaded True or False Mark for Review(1) PointsTrue ()FalseCorrect3 A cursors state is defined only by whether it is openor closed and if open how many rows it holds True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 11 Lesson 14 Users A and B call the same procedure in a package to initialize a global variable my_pkgg_var What will be the value of my_pkgg_varfor User A at Point AUser A my_pkgg_var is 10User B my_pkgg_var is 10User A my_pkgg_var is 50User B my_pkgg_var is 25Point AMark for Review(1) Points1050 ()25Correct1 Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1IF v_bool1 AND NOT v_bool2 AND v_number lt 25THEN--Line 1ELSEEND IFDBMS_OUTPUTNEW_LINEMark for Review(1) PointsDBMS_OUTPUTPUT(IF branch was executed) ()DBMS_OUTPUTPUT_LINE(IF branch was executed)DBMS_OUTPUTGET_LINE(IF branch was executed)DBMS_OUTPUTNEW_LINE(IF branch was executed)Incorrect Refer to Section 11 Lesson 22 The DBMS_OUTPUT package is useful for which of the foll

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 12: 10-13

owing activities (Choose two) Mark for Review(1) Points(Choose all correct answers)Interact with a user during execution of a function or procedureDisplay results to the developer during testing for debugging purposes()Trace the code execution path for a function or procedure ()Write operating system text files to the users screenCorrect3 The UTL_FILE package contains several exceptions exclusively used in this package Which are they (Choose 3) Mark for Review(1) Points(Choose all correct answers)INVALID_PATH ()NO_DATA_FOUNDWRITE_ERROR ()INVALID_OPERATION ()ZERO_DIVIDEIncorrect Refer to Section 11 Lesson 24 The UTL_FILE package can be used to read and write binary files such as JPEGs as well as text files True or False Mark for Review(1) PointsTrueFalse ()Correct5 Which general exceptions may be handled by the UTL_FILEpackage (Choose 2) Mark for Review(1) Points(Choose all correct answers)TOO_MANY_ROWSVALUE_ERROR ()ZERO_DIVIDENO_DATA_FOUND ()Correct6 The DBMS_OUTPUT gives programmers an easy-to-use interface to see for instance the current value of a loop counter or if a program makes it to a particular branch of an IF statement (True or False) Mark forReview(1) PointsTrue ()

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 13: 10-13

FalseCorrect7Mark for Review(1) Points(Choose all correct answers)It is used to append to a file until processing is complete ()It is used to read and write text files stored outside the database ()It is used to find out how much free space is left on an operating system diskIt is used to manipulate large object data type items in columnsIncorrect Refer to Section 11 Lesson 21 What will happen when the following procedure is invokedCREATE OR REPLACE PROCEDURE do_some_work ISCURSOR c_curs IS SELECT object_name FROM user_objectsWHERE object_type = FUNCTIONBEGINFOR v_curs_rec IN c_curs LOOPEXECUTE IMMEDIATE ALTER FUNCTION 10485761048576 v_curs_recobject_name 10485761048576 COMPILEEXIT WHEN c_cursROWCOUNT gt 2END LOOPENDMark for Review(1) PointsAll functions in the users schema will be recompiledThe first two functions in the users schema will be recompiledThe first three functions in the users schema will be recompiled ()The procedure will not compile successfully because you cannot ALTER functions using Dynamic SQLThe procedure will not compile successfully because the syntax of the ALTER FUNCTION statement is incorrectCorrect2 When SQL statements are included within a procedure the statements are parsed when the procedure is compiled True or False Mark forReview(1) Points

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 14: 10-13

True ()FalseCorrect3 Name two reasons for using Dynamic SQL Mark forReview(1) Points(Choose all correct answers)Avoid errrors at compile time of DML statementsCreate a SQL statement with varying column data or different conditions ()Enables data-definition statements to be written and executed from PLSQL ()Enables system control statements to be written and executed from PLSQLIncorrect Refer to Section 12 Lesson 14 Examine the following procedure which drops a table whose name is passed as an IN parameterCREATE OR REPLACE PROCEDURE drop_tab(p_table_name IN VARCHAR2) ISv_sql_statement VARCHAR2(100)BEGINENDWhich of the following will work correctly when coded in the procedures executable section (Choose two)Mark for Review(1) Points(Choose all correct answers)EXECUTE IMMEDIATE DROP TABLE p_table_nameEXECUTE IMMEDIATE DROP TABLE 10485761048576 p_table_name()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statement()v_sql_statement = DROP TABLE 10485761048576 p_table_nameEXECUTE IMMEDIATE v_sql_statementv_sql_statement = DROP TABLE EXECUTE IMMEDIATE v_sql_statement p_table_nameCorrect5 The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE True or False Mark for Review(1) Points

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 15: 10-13

TrueFalse ()Correct6 For which of the following is it necessary to use Dynamic SQL (Choose three) Mark for Review(1) Points(Choose all correct answers)ALTER ()GRANT ()SAVEPOINTUPDATEDROP ()Incorrect Refer to Section 12 Lesson 17 What happens when a SQL statement is parsed (Choose three) Mark for Review(1) Points(Choose all correct answers)The users required privileges are checked ()The syntax of the statement is checked ()The statement is executedThe results of the statement are returned to the userOracle queries the Data Dictionary to make sure that the tables referenced in the SQL statement exist ()Incorrect Refer to Section 12 Lesson 18 Only one call to DBMS_SQL is needed in order to drop atable True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 19 A programmer wants to code a procedure which will create a table with a single column The datatype of the column will be chosen by theuser who invokes the procedure The programmer writes the following codeCREATE OR REPLACE PROCEDURE create_tab(p_col_datatype IN VARCHAR2) ISBEGINCREATE TABLE newtab (only_col p_col_datatype)ENDWhy will this procedure not compile successfullyMark for Review(1) PointsBecause you cannot create a table inside a procedureBecause the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 16: 10-13

Because when the procedure is compiled Oracle cannot check if the parameter value passed into the procedure is a valid column datatype ()Because table NEWTAB may already existNone of the above the procedure will compile successfullyIncorrect Refer to Section 12 Lesson 11 In the following example where do you place the phraseBULK COLLECTBEGINSELECT -- Position Asalary -- Position BINTO v_saltab -- Position CFROM employees WHERE department_id = 20ORDER BY salary -- Position DMark for Review(1) PointsPosition APosition B ()Position CPosition DCorrect2 What is the main purpose for using the RETURNING clause Mark for Review(1) PointsImprove performance by returning a single valueImprove performance by minimizing the number of statementsImprove performance by making one call to the SQL engine ()Return more readily any exceptions that are raised by the statementIncorrect Refer to Section 12 Lesson 23 The following statement is a valid example of using theRETURNING clause True or FalseDECLARETYPE EmpRec IS RECORD (last_name employeeslast_nameTYPE salary employeessalaryTYPE)emp_info EmpRecemp_id NUMBER = 100BEGINUPDATE employees SET salary = salary 11WHERE employee_id = emp_idRETURNING last_name salary INTO emp_info

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 17: 10-13

dbms_outputput_line(Just gave a raise to 10485761048576 emp_infolast_name 10485761048576 who now makes 10485761048576 emp_infosalary)ENDMark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 12 Lesson 24 What are benefits of using the NOCOPY hint (Choose two) Mark for Review(1) Points(Choose all correct answers)Safer because it uses passing by valueEfficient since it uses less memory ()Uses a larger block of server memory for faster accessFaster because a single copy of the data is used ()Correct5 In the following example where do you place the phraseBULK COLLECTDECLARETYPE NameList IS TABLE OF empenameTYPEnames NameListCURSOR c1 IS SELECT ename -- Position AFROM emp WHERE job = CLERKBEGINOPEN c1FETCH c1 -- Position BINTO -- Position CnamesCLOSE c1ENDMark for Review(1) PointsPosition APosition B ()Position CCorrect6 A function-based index may be made using your own functions but only if the function is created using the DETERMINISTIC clause True or False Mark for Review(1) PointsTrue ()False

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 18: 10-13

Correct7 FORALL can only be used with the INSERT statement Trueor False Mark for Review(1) PointsTrueFalse ()Correct8 In the following example where do you place the phraseDETERMINISTICCREATE OR REPLACE FUNCTION total_sal(p_dept_id IN -- Position Aemployeesdepartment_idTYPE)RETURN NUMBER -- Position BIS v_total_sal NUMBERBEGINSELECT SUM(salary) INTO v_total_salFROM employees WHERE department_id = p_dept_inRETURN v_total_sal -- Position CEND total_salMark for Review(1) PointsPosition APosition B ()Position CCorrect9 What is wrong with this code exampleCREATE OR REPLACE PROCEDURE insert_emps ISTYPE t_emp IS TABLE OF employeesROWTYPE INDEXBY BINARY_INTEGERv_emptab t_empBEGINFORALL i IN v_emptabFIRSTv_emptabLASTINSERT INTO employees VALUES v_emptab(i)END LOOPEND insert_empsMark for Review(1) PointsThe phrase should be FOR ALLv_emptab is incorrectly typedFORALL does not require END LOOP ()Nothing is wrong it will compile successfullyIncorrect Refer to Section 12 Lesson 210 The following procedure compiles successfully True or FalseCREATE OR REPLACE PACKAGE emp_pkg ISTYPE t_emp IS TABLE OF employeesROWTYPE

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 19: 10-13

INDEX BY BINARY_INTEGERPROCEDURE emp_proc(p_small_arg IN NUMBER p_big_arg NOCOPY OUT t_emp)END emp_pkgMark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 12 Lesson 21 A database trigger is a PLSQL stored subprogram whichis explicitly invoked just like a procedure or a function True or FalseMark for Review(1) PointsTrueFalse ()Correct2 Which of the following are NOT allowed within a database trigger (Choose two) Mark for Review(1) Points(Choose all correct answers)COMMIT ()A call to a packaged procedureINSERTA Boolean variableSAVEPOINT ()Incorrect Refer to Section 13 Lesson 13 A business rule states that an employees salary must be between 4000 and 30000 We could enforce this rule using a check constraint but it is better to use a database trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 14 Which of the following are good guidelines to follow when creating triggers (Choose two) Mark for Review(1) Points(Choose all correct answers)Be aware of recursive and cascading effects ()Where possible use triggers to enforce NOT NULL constraintsAvoid lengthy trigger logic by creating a procedure and invoking it fromwithin the trigger ()

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 20: 10-13

Use triggers to replace functionality which is already built into the databaseAlways create more triggers than you need because it is better to be safeIncorrect Refer to Section 13 Lesson 15 Which of the following best describes a database trigger Mark for Review(1) PointsIt allows users to log on to the databaseIt executes automatically whenever a particular event occurs within thedatabase ()It prevents unique constraints from being violatedIt executes automatically whenever a user clicks on a button with theirmouseIt allows foreign key constraints to be violatedCorrect6 While editing a document in Microsoft Word you go to the FILE menu and SAVE your work To do this Microsoft Word has executed an application trigger True or False Mark for Review(1) PointsTrue ()FalseCorrect7 You can use a database trigger to prevent invalid transactions from being committed True or False Mark for Review(1) PointsTrue ()FalseCorrect8 Which of the following could NOT be done by a databasetrigger Mark for Review(1) PointsEnforcing a complex business ruleEnforcing a complex database security checkRecalculating the total salary bill for a department whenever an employees salary is changedEnsuring that a student never arrives late for a class ()Keeping a log of how many rows have been inserted into a tableIncorrect Refer to Section 13 Lesson 19 Which of the following events could NOT automatically f

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 21: 10-13

ire a database trigger Mark for Review(1) PointsA user logging on to the databaseA SQL INSERT statementYou click your mouse on a button to choose the correct answer to this question ()A DML operation on a viewThe Database Administrator shuts down the databaseIncorrect Refer to Section 13 Lesson 110 A users schema contains procedure MYPROC function MYFUNC trigger MYTRIGG and package MYPACK which contains a public procedure PACKPROC These subprograms have no parameters and the function returns a NUMBER Which of the following calls to these objects (from an anonymous block) are incorrect (Choose two) Mark for Review(1) Points(Choose all correct answers)mypackpackprocmytrigg ()myprocv_number = myfuncIF NOT myfunc THEN ()Incorrect Refer to Section 13 Lesson 11 An AFTER UPDATE trigger can specify more than one column True or False Mark for Review(1) PointsTrue ()FalseIncorrect Refer to Section 13 Lesson 22 We want to prevent employees from being deleted on Sundays To do this we create the following triggerCREATE OR REPLACE TRIGGER stop_del_emps DELETE ON employees -- Line ABEGINIF TO_CHAR(SYSDATEDY) = SUN THENRAISE_APPLICATION_ERROR(-20101Invalid delete)END IFENDShould this be a BEFORE or AFTER trigger and whyMark for Review(1) PointsIt should be a BEFORE trigger because if an AFTER trigger were created

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 22: 10-13

the employee would already have been deleted by the time the trigger checks thedate ()It should be a BEFORE trigger because you cannot use RAISE_APPLICATION_ERROR with AFTER triggersIt should be an AFTER trigger because the Oracle Server cannot fire thetrigger until it knows that the employee has been deletedIt does not matter either a BEFORE or an AFTER trigger could be createdCorrect3 Which of the following are possible keywords for the timing component of a trigger (Choose three) Mark for Review(1) Points(Choose all correct answers)BEFORE ()INSTEADWHENEVERINSTEAD OF ()AFTER ()Incorrect Refer to Section 13 Lesson 24 What is wrong with the following codeCREATE OR REPLACE TRIGGER mytriggAFTER DELETE ON departmentsBEGININSERT INTO audit_table (who when)VALUES (USER SYSDATE)COMMITENDMark for Review(1) PointsA DML trigger cannot itself contain a DML statement such as INSERT INTOaudit_tableYou cannot use COMMIT inside a trigger ()The last line of code should be END mytriggThe second line should be AFTER DELETE OF DEPARTMENTSNothing is wrong the trigger will execute successfullyIncorrect Refer to Section 13 Lesson 25 There are five employees in department 50 A statementtrigger is created byCREATE OR REPLACE TRIGGER emp_upd_triggAFTER DELETE ON EMPLOYEESBEGIN

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 23: 10-13

A user now executesDELETE FROM employees WHERE department_id = 50How many times will the trigger fire and whenMark for Review(1) PointsOnce before the DELETE is executedFive times after each employee row is deletedOnce after the DELETE is executed ()Six times once after each row and once at the end of the statementThe trigger will not fire at allCorrect6 Which of the following is the correct syntax for creating a DML trigger associated with the EMPLOYEES table The trigger must fire whenever an employees JOB_ID is updated but not if a different column is updatedMark for Review(1) PointsCREATE TRIGGER job_upd_triggAFTER UPDATE ON employees(job_id)BEGIN CREATE TRIGGER job_upd_triggWHENEVER UPDATE OF job_id IN employeesBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE ON employeesjob_idBEGIN CREATE TRIGGER job_upd_triggAFTER UPDATE OF job_id ON employeesBEGIN ()Incorrect Refer to Section 13 Lesson 27 A BEFORE statement trigger inserts a row into a loggingtable every time a user updates the salary column of the employees table The user now tries to update the salaries of three employees with a single UPDATE statement but the update fails because it violates a check constraint How many rows will be inserted into the logging table Mark for Review(1) PointsNone the transactions are rolled back because the update failed ()OneThree

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 24: 10-13

FourNone of the aboveIncorrect Refer to Section 13 Lesson 28 We want to create a log record automatically every timeany 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 Mark for Review(1) PointsOneTwo ()ThreeSixEightCorrect1 A row trigger has been created which is fired by UPDATEON 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 Mark forReview(1) PointsOnceTwiceFour times ()Five timesEight timesIncorrect Refer to Section 13 Lesson 32 The OLD and NEW qualifiers can be used with statement triggers as well as row triggers True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 33 Which of the following statements about INSTEAD OF triggers are NOT true (Choose two) Mark for Review(1) Points(Choose all correct answers)They can be created on a table ()They can be created on a simple viewThey can be created on a complex viewThey can be statement triggers ()They can be row triggersIncorrect Refer to Section 13 Lesson 34 You decide to create the following trigger

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 25: 10-13

CREATE OR REPLACE TRIGGER empl_triggBEFORE UPDATE ON employeesBEGIN-- Line ARAISE_APPLICATION_ERROR(Cannot update salary)ELSEINSERT INTO log_table values (USER SYSDATE)END IFENDYou want the trigger to prevent updates to the SALARY column but allow updatesto all other columns What should you code at Line AMark for Review(1) PointsIF UPDATING SALARY THENIF UPDATING(SALARY) THEN ()IF UPDATE(SALARY) THENIF UPDATING(SALARY) THENIF UPDATE(SALARY) THENIncorrect Refer to Section 13 Lesson 35 What is wrong with this compound trigger exampleCREATE OR REPLACE TRIGGER compound_triggerFOR UPDATE OF salaryCOMPOUND TRIGGERthreshold CONSTANT SIMPLE_INTEGER = 200BEFORE EACH ROW ISBEGIN-- some actionEND BEFORE EACH ROWAFTER EACH ROW ISBEGIN-- some actionEND AFTER EACH ROWAFTER STATEMENT ISBEGIN-- some actionEND AFTER STATEMENTEND compound_triggerMark for Review(1) PointsMissing BEFORE timing statementMissing the EXCEPTION sectionMissing name of table on which the trigger fires ()Missing the INSTEAD OF timing sectionMissing the BEFORE and INSTEAD OF timing sectionsIncorrect Refer to Section 13 Lesson 3

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 26: 10-13

6 Which of the following best describes conditional predicates in a trigger Mark for Review(1) PointsThey are special variables which must be DECLAREd within the triggerThey allow the trigger code to see what data values are being inserted into a rowThey 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 NOTFOUNDCorrect7 Whenever an employees 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 codeBEGININSERT INTO logging_table (emp_id job_id)VALUES -- Point AENDAt point A which of the following will insert the correct data into the loggingtable (Choose two)Mark for Review(1) Points(Choose all correct answers)(OLDemployee_id OLDjob_id)(OLDemployee_id NEWjob_id) ()(NEWemployee_id OLDjob_id)(NEWemployee_id NEWjob_id) ()(NEWemployee_id NEWjob_id)Incorrect Refer to Section 13 Lesson 38 Examine the following code To create a row trigger what code should be included at Line ACREATE OR REPLACE TRIGGER del_emp_triggBEFORE DELETE ON employees---- Line ABEGIN Mark for Review(1) PointsFOR EVERY ROWFOR EACH ROW ()FOR EVERY ROWFOR ALL ROWS

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 27: 10-13

Nothing is needed because DML triggers are row triggers by defaultCorrect9 The following view and trigger have been createdCREATE VIEW dept_view AS SELECT FROM departmentsCREATE OR REPLACE TRIGGER dept_view_triggINSTEAD OF UPDATE ON dept_viewBEGINDBMS_OUTPUTPUT_LINE(Sample Message)ENDDepartments 50 and 80 exist but department 81 does not A user now executes thefollowing statementUPDATE dept_view SET department_name = SalesWHERE department_id IN (508081)What happensMark for Review(1) PointsTwo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed onceNo rows are updated and Sample Message is displayed twice ()No rows are updated and Sample Message is displayed three timesNone of the aboveIncorrect Refer to Section 13 Lesson 310 What are the timing events for a compound triggerMark for Review(1) PointsBefore the triggering statement After the triggering statement Insteadof the triggering statementBefore the triggering statement Before each row After each row Afterthe triggering statement ()Before the triggering statement After the triggering statement After each rowBefore the triggering statement Before each row After the triggering statementCorrect1 You can create a trigger which prevents DDL statementson an individual table while still allowing DDL on other tables in the same schema True or False Mark for Review(1) Points

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 28: 10-13

TrueFalse ()Correct2 What is wrong with the following codeCREATE OR REPLACE TRIGGER call_triggAFTER UPDATE OR DELETE ON employeesBEGINCALL del_emp_procENDMark for Review(1) PointsWhen 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 triggerWhen using CALL only one DML statement can be tested so UPDATE OR DELETE is wrongCorrect3 The database administrator creates a trigger that automatically disconnects user HACKER whenever HACKER connects to the database Whattype of trigger is this Mark for Review(1) PointsA DDL triggerA Database Event trigger ()A DML triggerA statement triggerAn INSTEAD OF triggerIncorrect Refer to Section 13 Lesson 44 What is wrong with the following codeCREATE OR REPLACE TRIGGER emp_dml_triggBEFORE UPDATE OF salary ON employeesFOR EACH ROWDECLAREv_max_sal employeessalaryTYPEBEGINSELECT max(sal) INTO v_max_sal FROM employeesENDMark for Review(1) PointsYou cannot use a DECLARE statement in a triggerThe trigger body is reading the same table (employees) that the triggering event is updating ()You must use RAISE_APPLICATION_ERROR in a BEFORE triggerYou can never use SELECT inside a DML trigger

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 29: 10-13

Nothing is wrong the trigger will execute correctlyIncorrect Refer to Section 13 Lesson 45 The database administrator wants to write a log recordevery time any users session raises an ORA-00942 exception The DBA decides tocreate the following triggerCREATE OR REPLACE TRIGGER log_942_triggAFTER SERVERERROR ON DATABASEBEGIN-- Line AINSERT INTO log_table VALUES ( )ENDWhat should the DBA code at Line AMark for Review(1) PointsIF (SERVERERROR(942)) THENIF (IS_SERVERERROR(942)) THEN ()IF (SERVERERROR = 942) THENIF (IS_SERVERERROR = 942) THENIF (IS_SERVERERROR(ORA-00942)) THENIncorrect Refer to Section 13 Lesson 46 Which of the following could NOT cause a DDL or Database Event trigger to fire Mark for Review(1) PointsA table is droppedA user connects to the databaseThe DBA starts up the databaseA user deletes rows from the EMPLOYEES table ()A specific exception is raised in a users sessionIncorrect Refer to Section 13 Lesson 47 User HARJIT wants to prevent any objects which he ownsfrom being dropped Harjit decides to execute the following codeCREATE OR REPLACE TRIGGER stop_drop---- Line ABEGINRAISE_APPLICATION_ERROR(-20201Attempted drop)ENDWhat should Harjit code at Line AMark for Review(1) PointsBEFORE DROP ON HARJITBEFORE DROP ON TABLEBEFORE DROP ON SCHEMA ()BEFORE DROP ON OWNERBEFORE DROP ON USER_OBJECTS

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 30: 10-13

Incorrect Refer to Section 13 Lesson 48 You have been granted CREATE TRIGGER privilege You cannow create an AFTER LOGOFF ON SCHEMA trigger True or False Mark for Review(1) PointsTrueFalse ()Incorrect Refer to Section 13 Lesson 49 Mutating table errors can be caused by DML triggers but not by database event triggers True or False Mark for Review(1) PointsTrue ()FalseCorrect10 What is the benefit of using the CALL statement in a trigger body Mark for Review(1) PointsIt allow both DDL events and database events to be handled by a single triggerIt prevents data being read from a mutating tableIt allows the database administrator to monitor who is currently connected to the databaseIt allows the trigger body code to be placed in a separate procedure ()Incorrect Refer to Section 13 Lesson 4 User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG which are both DML triggers referencing her EMPLOYEES table Kuljit now wants to remove both of these triggers from the database What command(s) should Kuljit use to do this Mark for Review(1) PointsDROP ALL TRIGGERS ON employeesDROP TRIGGERS ON employeesDROP TRIGGER emp1_triggDROP TRIGGER emp2_trigg()DROP TRIGGER emp1_trigg AND emp2_triggIncorrect Refer to Section 13 Lesson 52 You have created several DML triggers which reference your DEPARTMENTS table Now you want to disable all of them using a single SQL statement Which command should you use Mark for Review

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 31: 10-13

(1) PointsALTER TRIGGER DISABLE ALL ON departmentsALTER TABLE departments DISABLE ALL TRIGGERS ()ALTER TABLE departments DISABLE TRIGGERSDROP ALL TRIGGERS ON departmentsCorrect3 Which dictionary view would you query to see the detailed body code of triggers in your schema Mark for Review(1) PointsUSER_SOURCEUSER_TRIGGERUSER_TRIGGERS ()USER_OBJECTSNone of the above you cannot view the code of the trigger body after the trigger has been createdCorrect4 A user creates the following triggerCREATE OR REPLACE TRIGGER emp_triggAFTER DELETE ON employeesBEGINENDThe user now tries to drop the EMPLOYEES table What happensMark for Review(1) PointsThe table is dropped but the trigger is not droppedAn error message is displayed because you cannot drop a table that is referenced by a triggerThe table is dropped and the trigger is disabledBoth the table and the trigger are dropped ()Incorrect Refer to Section 13 Lesson 55 Which command would you use to see if your triggers areenabled or disabled Mark for Review(1) PointsSELECT trigger_name statusFROM USER_TRIGGERS()SELECT object_name statusFROM USER_OBJECTSWHERE object_type = TRIGGERSELECT trigger_name trigger_typeFROM USER_TRIGGERSDESCRIBE TRIGGERIncorrect Refer to Section 13 Lesson 5

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct

Page 32: 10-13

6 By default any user can create a DML trigger on a table in hisher schema True or False Mark for Review(1) PointsTrueFalse ()Correct