Examine this package
CREATE OR REPLACE PACKAGE discounts
IS
g_id NUMBER := 7839;
discount _rate NUMBER := 0.00;
PROCEDURE display_price (p_price NUMBER);
END discounts;
/
CREATE OR REPLACE PACKAGE BODY discounts
IS
PROCEDURE display_price (p_price NUMBERI)
IS
BEGIN
DBMS_OUTPUT.PUT LINE ( ‘Discounted ‘||
TO_CHAR(p_price*NVL(dlscount_rate, 1)));
END display_price;
BEGIN
Discount_rate = 0.10;
END discounts;
/
The SQL*Plus SERVEROUTPUT setting is turned on in your session. You execute the procedure
DISPLAY_PRICE from SQL*Plus with the command EXECUTE discounts. display_price (100);
What is the result?
A.
Discounted 10
B.
Discounted 100
C.
Discounted 0.00
D.
Discounted NULL
E.
Discounted 0.10
Explanation:
The discounts package contains a one-time-only procedure which is executed when the package
is first referenced and sets the public variable discount_rate = .10. The value of 100 is passed to
the p_price parameter and this is multipled by the discount_rate resulting in a value of ‘Discounted
10′ is displayed by the DBMS_OUTPUT.PUT_LINE.