Sie sind auf Seite 1von 7

Test: Quiz: Advanced Package Concepts 1.

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 us e forward declarations. True or False? Mark for Review (1) Points True (*) False

Correct 2. When using a package function in DML statements, which rules must you f ollow? (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 statement Changes to a package variable could have an impact on another stored fun ction (*) Cannot execute a DML statement or modify the database (*)

Correct 3. The following package is valid. True or False? CREATE OR REPLACE PACKAGE exceptions_pkg IS e_cons_violation EXCEPTION; PRAGMA EXCEPTION_INIT (e_cons_violation, -2292); e_value_too_large EXCEPTION; PRAGMA EXCEPTION_INIT (e_value_too_large, -1438); END exceptions_pkg; Mark for Review (1) Points True (*) False

Correct

4. How would you invoke the constant km_to_mile from the global_consts bod iless package at VARIABLE A? SELECT trail_name, distance_in_km * VARIABLE A FROM trails WHERE park_name = 'YOSEMITE'; Mark for Review (1) Points km_to_mile.global_consts km_to_mile (global_consts) global_consts.km_to_mile (*) global_consts (km_to_mile)

Correct 5. Examine the following package code: CREATE OR REPLACE PACKAGE over_pack IS PROCEDURE 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 DATE; END over_pack; Which of the following calls will be successful? (Choose three.) Mark for Review (1) Points (Choose all correct answers) over_pack.do_work1('Smith',20); v_date := over_pack.do_work2('Smith',20); (*) over_pack.do_work2('Smith',20); (*) over_pack.do_work1(p1=>'Smith',p2=>20); (*) over_pack.do_work1(param1=>'Smith');

Correct 6. Which of the following best describes a package initialization block?

Mark for Review (1) Points It is a named procedure in a package which must be invoked by a user bef ore any other part of the package can be invoked. It is an anonymous block in the package specification. It is an anonymous block at the end of a package body which executes aut omatically the first time each user session invokes a subprogram in the package. (*) It is a private function within the package body. Because it is an anonymous block, it cannot be invoked and therefore wil l never execute. It is treated as a set of comments.

Correct 7. A bodiless package contains what? (1) Points Procedures only Functions only Public variables only (*) Private variables only Mark for Review

Correct 8. Which two of FUNCTION get_emp (p1 FUNCTION get_emp (p1 FUNCTION get_emp (p1 FUNCTION get_emp (p1 Mark for Review (1) Points 1 and 2 1 and 4 these functions could not be in the same package? DATE) RETURN VARCHAR2; DATE, p2 NUMBER) RETURN VARCHAR2; DATE, p2 NUMBER) RETURN NUMBER; NUMBER, p2 DATE) RETURN VARCHAR2;

2 and 4 2 and 3 (*) 3 and 4

Correct 9. The following example package specification is valid to create a data ty pe ed_type that can be used in other subprograms. True or False? CREATE OR REPLACE PACKAGE emp_dept_pkg IS TYPE ed_type IS RECORD (f_name employees.first_name%TYPE, l_name employees.last_name%TYPE, d_name departments.department_name%TYPE); PROCEDURE sel_emp_dept (p_emp_id IN employees.employee_id%TYPE, p_emp_dept_rec OUT ed_type); END emp_dept_pkg; Mark for Review (1) Points True (*) False

Correct 10. A package initialization block is executed automatically every time a u ser invokes any procedure or function in the package. True or False? Mark for Review (1) Points True False (*)

Correct 11. The package name must be included when calling a package function from a SELECT statement executed outside the package. True or False? Mark for Review (1) Points True (*) False

Correct 12. Which one of the following is NOT a restriction on a package function c alled from a SQL statement? Mark for Review (1) Points The function can include a COMMIT. The function can be overloaded. (*) The function can include a ROLLBACK. The function can return a BOOLEAN.

Correct 13. INDEX BY is missing from this package declaration. What is the most effi cient declaration? CREATE OR REPLACE PACKAGE emp_pkg IS TYPE emp_tab IS TABLE OF employees%ROWTYPE; PROCEDURE get_employees(p_emp_table OUT emp_tab); END emp_pkg; Mark for Review (1) Points INDEX BY INTEGER INDEX BY BINARY INDEX BY BINARY_INTEGER (*) INDEX ALL

Correct 14. Package FORWARD_PACK contains two procedures: PROC1 is public while PRO C2 is private (not declared in the package specification). These procedures have no parameters. Which of the following package bodies will NOT compile successfu lly? (Choose two.) Mark for Review (1) Points (Choose all correct answers)

CREATE OR REPLACE PACKAGE BODY forward_pack IS PROCEDURE proc1 IS BEGIN proc2; END; PROCEDURE proc2 IS BEGIN DBMS_OUTPUT.PUT_LINE('Any message'); END; END forward_pack; (*)

CREATE OR REPLACE PACKAGE BODY forward_pack IS PROCEDURE proc2 IS BEGIN DBMS_OUTPUT.PUT_LINE('Any message'); END; PROCEDURE proc1 IS BEGIN proc2; END; END forward_pack; CREATE OR REPLACE PACKAGE BODY forward_pack IS PROCEDURE proc2; PROCEDURE proc1 IS BEGIN proc2; END; PROCEDURE proc2 IS BEGIN DBMS_OUTPUT.PUT_LINE('Any message'); END; END forward_pack; CREATE OR REPLACE PACKAGE BODY forward_pack IS PROCEDURE proc1; PROCEDURE proc1 IS BEGIN proc2; END; PROCEDURE proc2 IS proc1; END; END forward_pack; (*)

CREATE OR REPLACE PACKAGE BODY forward_pack IS PROCEDURE proc2; PROCEDURE proc1 IS BEGIN proc2; END; PROCEDURE proc2 IS

BEGIN proc1; END; END forward_pack;

Correct