P2 - BDD
P2 - BDD
DECLARE
v_weight NUMBER(3) := 600;
v_message VARCHAR2(255) := 'Product 10012';
BEGIN
/*SUBBLOCK*/
DECLARE
v_weight NUMBER(3) := 1;
v_message VARCHAR2(255) := 'Product 11001';
v_new_locn VARCHAR2(50) := 'Europe';
BEGIN
v_weight := v_weight + 1;
v_new_locn := 'Western ' || v_new_locn;
1 END;
v_weight := v_weight + 1;
v_message := v_message || ' is in stock';
v_new_locn := 'Western ' || v_new_locn;
2 END;
/
1. Evaluate the PL/SQL block above and determine the data type and value of each of the following
variables according to the rules of scoping.
a. The value of V_WEIGHT at position 1 is:
2
The data type is NUMBER.
b. The value of V_NEW_LOCN at position 1 is:
Western Europe
The data type is VARCHAR2.
c. The value of V_WEIGHT at position 2 is:
601
The data type is NUMBER.
d. The value of V_MESSAGE at position 2 is:
Product 10012 is in stock
The data type is VARCHAR2.
e. The value of V_NEW_LOCN at position 2 is:
Illegal because v_new_locn is not visible outside the subblock.
END;
/
b. Pass these two values defined in step a above, to the PL/SQL block through iSQL*Plus
substitution variables. The first number should be divided by the second number and have the
second number added to the result. The result should be stored in a PL/SQL variable and printed
on the screen.
Note: SET VERIFY OFF in the PL/SQL block.