Sie sind auf Seite 1von 5

Test: Quiz: Advance Package Concepts Bekijk uw antwoorden, feedback en scores hieronder.

Een asterisk (*) geeft een goed antwoord aan. Section 1 (Beantwoord alle vragen in deze sectie.) 1. 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.) (Kies alle goede antwoorden.) 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 2. A package initialization block is executed automatically every time a user invokes any procedure or function in the package. True or False? Waar Niet waar (*) Correct 3. A bodiless package contains what? Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten

Procedures only Functions only Public variables only (*) Private variables only Correct 4. Which one of the following is NOT a restriction on a package function called from a SQL statement? The function can include a COMMIT. The function can be overloaded. (*) The function can include a ROLLBACK. The function can return a BOOLEAN. Markeren voor nakijken (1) Punten

Correct 5. Package FORWARD_PACK contains two procedures: PROC1 is public while PROC2 is private (not declared in the package specification). These procedures have no parameters. Which of the following package bodies will NOT compile successfully? (Choose two.) (Kies alle goede antwoorden.) 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; Markeren voor nakijken (1) Punten

END forward_pack; Correct 6. Which two of these functions could not be in the same package? Markeren voor nakijken (1) Punten

1.
2. 3. 4.

FUNCTION FUNCTION FUNCTION FUNCTION

get_emp get_emp get_emp get_emp

(p1 (p1 (p1 (p1

DATE) RETURN VARCHAR2; DATE, p2 NUMBER) RETURN VARCHAR2; DATE, p2 NUMBER) RETURN NUMBER; NUMBER, p2 DATE) RETURN VARCHAR2;

1 and 2 1 and 4 2 and 4 2 and 3 (*) 3 and 4 Correct 7. The following example package specification is valid to create a data type 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; Waar (*) Niet waar Correct 8. When using a package function in DML statements, which rules must you follow? (Choose three) (Kies alle goede antwoorden.) 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 function (*) Cannot execute a DML statement or modify the database (*) Correct 9. Which of the following best describes a package initialization block? Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten

It is a named procedure in a package which must be invoked by a user before 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 automatically 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 will never execute. It is treated as a set of comments. Correct 10. How would you invoke the constant km_to_mile from the global_consts bodiless package at VARIABLE A? SELECT trail_name, distance_in_km * VARIABLE A FROM trails WHERE park_name = 'YOSEMITE'; km_to_mile.global_consts km_to_mile (global_consts) global_consts.km_to_mile (*) global_consts (km_to_mile) Correct 11. 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; Waar (*) Niet waar Correct 12. INDEX BY is missing from this package declaration. What is the most efficient 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; INDEX BY INTEGER INDEX BY BINARY INDEX BY BINARY_INTEGER (*) INDEX ALL Correct 13. The package name must be included when calling a package function from a SELECT statement executed outside the package. True or False? Waar (*) Niet waar Correct Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten Markeren voor nakijken (1) Punten

14. 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? Waar (*) Niet waar Correct

Markeren voor nakijken (1) Punten

Das könnte Ihnen auch gefallen