Examine this package:
CREATE OR REPLACE PACKAGE BB_PACK
IS
V_MAX_TEAM_SALARY NUMBER(12,2);
PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY
NUMBER);
END BB_PACK;
/
CREATE OR REPLACE PACKAGE BODY BB_PACK
IS
V_PLAYER_AVG NUMBER(4,3);
PROCEDURE UPD_PLAYER_STAT
V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER)
IS
BEGIN
UPDATE PLAYER_BAT_STAT
SET AT_BATS = AT_BATS + V_AB,
HITS = HITS + V_HITS
WHERE PLAYER_ID = V_ID;
COMMIT;
VALIDATE_PLAYER_STAT(V_ID);
END UPD_PLAYER_STAT;
PROCEDURE ADD_PLAYER
(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER)
IS
BEGIN
INSERT INTO PLAYER(ID,LAST_NAME,SALARY)
VALUES (V_ID, V_LAST_NAME, V_SALARY);
UPD_PLAYER_STAT(V_ID,0,0);
END ADD_PLAYER;
END BB_PACK
/
Which statement will successfully assign .333 to the V_PLAYER_AVG variable from a procedure outside the package?
A.
V_PLAYER_AVG := .333;
B.
BB_PACK.UPD_PLAYER_STAT.V_PLAYER_AVG := .333;
C.
BB_PACK.V_PLAYER_AVG := .333;
D.
This variable cannot be assigned a value from outside of the package.
Explanation:
Constructs declared and defined in the package body are private constructs and they can’t be
invoked outside of the package.
Incorrect Answers:
A: Even if this variable was declared in the package specification, this is the wrong syntax for
referencing a global variable from outside the package.
B: Nice try but this is wrong, you can’t reference a package that is defined in the package body
from outside of the package.C. This is the correct syntax for assigning a value to a global variable
but this is wrong because the variable was not declared in the package specification.