0% found this document useful (0 votes)
2K views4 pages

Quiz 10

The document contains questions about Oracle PL/SQL packages, including questions about package specifications and bodies, public and private components, invoking package subprograms from within and outside of packages, and other features of packages. It tests knowledge of how to declare, define, and use different elements within packages including procedures, functions, variables, and exceptions. The questions cover topics like which components can reference other components, where subprograms can be invoked from, and how to view package source code and metadata.

Uploaded by

Isaac Yañez W
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views4 pages

Quiz 10

The document contains questions about Oracle PL/SQL packages, including questions about package specifications and bodies, public and private components, invoking package subprograms from within and outside of packages, and other features of packages. It tests knowledge of how to declare, define, and use different elements within packages including procedures, functions, variables, and exceptions. The questions cover topics like which components can reference other components, where subprograms can be invoked from, and how to view package source code and metadata.

Uploaded by

Isaac Yañez W
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Quiz 10

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;

6 (*)

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

True (*)

Package NEWPACK contains several procedures and functions, including private function PRIVFUNC. From
where can PRIVFUNC be invoked? (Choose two.)

From any procedure in NEWPACK (*)


From any function in NEWPACK (*)

Examine the following package specification:

CREATE OR REPLACE PACKAGE mypack IS


percent_tax NUMBER := 20;
PROCEDURE proc1;
END mypack;

The package body of mypack also includes a function called func1. Which of the following statements are
true? (Choose three.)

proc1 is a public procedure and func1 is a private function. (*)

The procedure can be invoked by:


BEGIN
mypack.proc1;
END; (*)

The variable can be modified by:


BEGIN
mypack.percent_tax := 10;
END; (*)

A local variable declared within a procedure in a package can be referenced by any other component of that
package. True or False?

False (*)

To be able to invoke a package subprogram from outside the package, it must be declared in the package:

Body and the specification (*)

Which of the following can be included in a package?

All of these. (*)


Package EMP_PACK contains two procedures, DEL_EMP and SHOW_EMP. You want to write an anonymous
block which invokes these procedures but you have forgotten which parameters they use. Which of the
following will give you this information?

DESCRIBE emp_pack (*)

Which of the following statements about packages is NOT true ?

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

Every subprogram which has been declared in a package specification must also be included in the package
body. Triue or False?

True (*)

Examine the following code:

CREATE OR REPLACE PACKAGE emppack IS


PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER);
END emppack;
CREATE OR REPLACE PACKAGE BODY emppack IS
-- Line A
PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER) IS
BEGIN
IF NOT sal_ok(p_salary) THEN
RAISE_APPLICATION_ERROR(-20201,'Invalid salary');
END IF;
END upd_emp;
FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN IS
BEGIN
IF pf_salary > 50000 THEN RETURN FALSE;
ELSE RETURN TRUE;
END IF;
END sal_ok;
END emppack;

What must be coded at Line A for this package to compile successfully?

FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN; (*)

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 (*)

Which of the following statements about a package initialization block is true?

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

The following call to the function tax in the taxes_pkg package is invalid for what reason?

SELECT taxes_pkg.tax(salary), salary, last_name


FROM employees;

The call to the package is valid and will execute without error. (*)

Which of the following are not allowed in a bodiless package? (Choose three)

(Seleccione todas las respuestas correctas)


Subprograms (*)
DML statements (*)
Private variables (*)

Which one of the following queries would you use to see the detailed code of a package called EMP_PKG?

SELECT text FROM user_source WHERE name = 'EMP_PKG' AND type = 'PACKAGE BODY' ORDER BY line; (*)

When one component of a package is called, all the package's components are loaded into memory. True or
False?

True (*)

In a package, public components are declared in the specification but private components are not. True or
False?

True (*)

SCOTT's schema contains a package EMP_PKG which contains a public procedure EMP_SAL which accepts a
NUMBER parameter. Which of the following will invoke the procedure successfully?

scott.emp_pkg.emp_sal(101): (*)

We never need to use a forward declaration when invoking a public subprogram. True or False?

True (*)

The following example shows a valid record data type and variable. True or False?

TYPE DeptRecTyp
IS RECORD (deptid NUMBER(4) NOT NULL := 99,
dname departments.department_name%TYPE,
loc departments.location_id%TYPE,
region regions.region_id%TYPE );
dept_rec DeptRecTyp;

True (*)

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';

global_consts.km_to_mile (*)

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;

True (*)

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

True (*)

Which part of a package must be created first, the specification or the body?

The specification (*)


In which component of a package is the full definition of a public procedure written?

Body (*)

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.)

CREATE PROCEDURE dept_proc IS


v_deptname VARCHAR2(20);
BEGIN
v_deptname := dept_pack.get_dept(40);
END; (*)

You might also like