Which two statements are correct about PL/SQL package components?

Which two statements are correct about PL/SQL package components? (Choose two)

Which two statements are correct about PL/SQL package components? (Choose two)

A.
A package must have both specification and body.

B.
A package body can exist without the package specification.

C.
A package specification can exist without the package body.

D.
When a packaged public variable is called for the first time in a session, the entire package is loaded into memory.



Leave a Reply 10

Your email address will not be published. Required fields are marked *


vanca

vanca

Sorry I meant B and D because a package body can exists without specification because in this case the procedure will be private
http://stackoverflow.com/questions/4682528/procedure-listed-in-package-body-but-not-spec

Kelvin

Kelvin

not B because u cannot create body without specification. you don’t need to define in specification and that is how you make it private.

SamD

SamD

In the link you specified, he was talking about the private subprograms which are declared in the body. He doesn’t mean that package body can exists without package specification.

Jo

Jo

Response is C and D.
A package body cannot exist without package specification.
@vanca You are mistaken the package specification and the procedure specification. If you want to create a private procedure, you’ll not declare it in the package specification which is not possible with a package.

Hector Gonzalez

Hector Gonzalez

Las respuesta a estas preguntas son las siguientes:

C) A package specification can exist without the package body.

Ya que en el Student Guide – Volume I, Oracle Database: Develop PL/SQL Program Units, Módulo 3, Creating Packages, en la lamina “What Are PL/SQL Packages?”, se indica lo siguiente:

Un package por lo general tienen 2 partes:

* una especificación (espec)
* un cuerpo(body) (opcional)
Por lo tanto un package puede ser definido sin un body, solo es obligatorio definir la especification.

D) When a packaged public variable is called for the first time in a session, the entire package is loaded into memory.

en la misma lámina del student guide referenciado anteriormente, indica que cuando se hacer referencia a un paquete por primera vez, el paquete entero en cargado en memoria, por lo tanto futuras referencias a algún miembro del paquete no requiere realizar operaciones de lectura/escritura de disco.
Esta característica permite que se incremente el desempeño dentro del Oracle server, debido a que el paquete entero es colocado en memoria la primera vez que se referencia. Esto coloca una sola copia del paquete en memoria para todo los usuarios. También elimina la dependencia en cascada y así evitar compilación innecesaria.

SK

SK

SQL> create or replace FUNCTION increase (emp_num number) RETURN NUMBER is
2 inc_amt NUMBER;
3 sal NUMBER;
4 BEGIN
5 select salary into sal from employees where employee_id= emp_num;
6 inc_amt:=sal*.1;
7 RETURN inc_amt;
8 END INcrease;
9 /

Function created.

SQL> create or REPLACE PROCEDURE calc_sal is
2 emp_num NUMBER(6):=120;
3 amt NUMBER:=0;
4 procedure raise_salary(emp_id NUMBER) is
5 BEGIN
6 amt:= increase(emp_num);
7 UPDATE employees set salary= salary+amt where employee_id= emp_id;
8 end raise_salary;
9 BEGIN
10 raise_salary(emp_num);
11 end calc_sal;
12 /

Procedure created.