Halaman

Monday, August 26, 2019

Answer Section 10 Quiz Database Programming with PL/SQL 2019 Learner - English


Section 10


Which two of these declarations cannot be in the same package specification?
PROCEDURE myproc (p1 NUMBER, p2 VARCHAR2);
PROCEDURE myproc (p1 VARCHAR2, p2 NUMBER);
PROCEDURE myproc (p1 NUMBER, p2 CHAR);
PROCEDURE myproc (p1 NUMBER);
                                                        
                                               
                1 and 3 (*)

                                               
                3 and 4

                                               
                1 and 4

                                               
                2 and 3

                                               
                1 and 2

                                                                               
                                                               
Which of the following statements about a package initialization block is true?   
                                                                               
                                               
                It is an anonymous block in the package specification.

                                               
                It is executed automatically every time any global variable in the package is referenced.

                                               
                It is an anonymous block at the end of a package body. (*)

                                               
                It cannot contain any SQL statements.

                                               
                It is a procedure in a package that must be invoked before the rest of the package can be used.

                                                                               
Package HRPACK contains the following public function:
FUNCTION empfunc (p_deptno NUMBER) RETURN NUMBER IS
BEGIN
    UPDATE employees
    SET salary = salary * 1.1
       WHERE department_id = p_deptno;
    RETURN SQL%ROWCOUNT;
END empfunc;

What will happen when the following SQL statement is executed?

SELECT department_name, hrpack.empfunc(department_id)
FROM departments;
                                                          
                                               
                The SELECT will fail because you cannot execute a DML statement from within a query.

                                               
                The SELECT will fail because you cannot return SQL%ROWCOUNT from a packaged function.

                                               
                The SELECT will succeed because it is referencing a different table from the function. (*)

                                               
                The SELECT will fail because you cannot call packaged functions from within a SQL statement.

                                                                               
                                                               
INDEX BY is missing from the emp_tab TYPE 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 ALL

                                               
                INDEX BY BINARY

                                               
                INDEX BY INTEGER

                                               
                INDEX BY BINARY_INTEGER (*)

                                                                               
                                                               
Which two of these functions could not be in the same package?

1. FUNCTION get_emp (p1 DATE) RETURN VARCHAR2;
2. FUNCTION get_emp (p1 DATE, p2 NUMBER) RETURN VARCHAR2;
3. FUNCTION get_emp (p1 DATE, p2 NUMBER) RETURN NUMBER;
4. FUNCTION get_emp (p1 NUMBER, p2 DATE) RETURN VARCHAR2;       
                                                                               
                                               
                2 and 3 (*)

                                               
                1 and 2

                                               
                2 and 4

                                               
                1 and 4

                                               
                3 and 4


Package MYPACK contains procedure MYPROC. You can see which parameters MYPROC uses by executing: DESCRIBE mypack.myproc. True or False?            
                                                                               
                                               
                True

                                               
                False (*)

                                                                               
                                                               
A number variable declared in a package is initialized to NULL unless assigned another value. True or False?   
                                                                               
                                               
                True (*)

                                               
                False

                                                                               
                                                               
In which component of a package is the full definition of a public procedure written?     
                                                                               
                                               
                Body (*)

                                               
                Neither the body nor the specification

                                               
                Both the body and the specification

                                               
                Specification

                                                                               
                                                               
Which of the following statements about packages is NOT true ?          
                                                                               
                                               
                The specification must be created before the body.

                                               
                Cursors can be declared in the specification.

                                               
                The body contains the detailed code of the subprograms.

                                               
                All procedures and functions must be declared in the specification. (*)

                                               
                Variables can be declared in the body.

                                                                               
                                                               
Which part of a package must be created first, the specification or the body?      
                                                                               
                                               
                The specification and body must be created at the same time.

                                               
                The body

                                               
                The specification (*)

                                               
                It does not matter which is created first.

                                               
                The body can be created first, but only if the package has no specification.

Examine the following package specification:
CREATE OR REPLACE PACKAGE taxpack IS
    CURSOR empcurs IS SELECT * FROM employees;
    PROCEDURE taxproc;
END mypack;

The package body of TAXPACK also includes a function called TAXFUNC. Which one of the following statements is NOT true?
                                                            
                                               
                TAXPROC is public and TAXFUNC is private.

                                               
                The procedure can be invoked by:
BEGIN
    taxpack.taxproc;
END;


                                               
                The package will not compile because you cannot declare a cursor in the specification.
(*)


                                               
                TAXPROC can invoke TAXFUNC if TAXPROC is coded before TAXFUNC.

                                               
                TAXPROC can open the cursor.

                                                                               
                                                               
A public component declared in the package specification can be referenced by a private component defined in the package body. True or False?       
                                                                               
                                               
                True (*)

                                               
                False

                                                                               
                                                               
What will be displayed when a user executes the following statement?
SELECT object_name FROM user_objects
    WHERE object_type LIKE 'PACK%';

                                                                               
                                               
                The detailed code of all packages in the user's schema

                                               
                The parameters which must be used when invoking all packaged subprograms in the user's schema

                                               
                The names of all packages which can be invoked by the user

                                               
                The names of all package specifications and package bodies in the user's schema (*)

                                               
                The names of all package specifications in the user's schema

                                                                               
                                                               
Your schema contains four packages, each having a specification and a body. You have also been granted privileges to access three packages (and their bodies) in other users' schemas. What will be displayed by the following query?
SELECT COUNT(*) FROM ALL_OBJECTS
    WHERE object_type LIKE 'PACK%'
    AND owner <> USER;

                                                                               
                                               
                7

                                               
                14

                                               
                3

                                               
                0

                                               
                6 (*)

                                                                               
                                                               
Package OLDPACK is in your schema. What will happen when the following statement is executed?
DROP PACKAGE oldpack;
                                                       
                                               
                The body will be dropped but the specification will be retained.

                                               
                The specification will be dropped but the body will be retained.

                                               
                The statement will fail because you must drop the body before you can drop the specification.

                                               
                Both the specification and the body will be dropped. (*)

No comments:

Post a Comment

Final Exam Java Programming 2019 Learner - English

Final Exam