Professional Documents
Culture Documents
P1 - BDD
P1 - BDD
1. Evaluate each of the following declarations. Determine which of them are not legal and explain
why.
a. DECLARE
v_id NUMBER(4);
Legal
b. DECLARE
v_x, v_y, v_z VARCHAR2(10);
Illegal because only one identifier per declaration is allowed.
c. DECLARE
v_birthdate DATE NOT NULL;
Illegal because the NOT NULL variable must be initialized.
d. DECLARE
v_in_stock BOOLEAN := 1;
Illegal because 1 is not a Boolean expression.
PL/SQL returns the following error:
PLS-00382: expression is of wrong type
d. v_flag := TRUE;
Valid; Boolean
f. v_value := NULL;
Valid; Any scalar data type
3. Create an anonymous block to output the phrase “My PL/SQL Block Works” to the screen.
Alternate Solution:
SET SERVEROUTPUT ON
BEGIN
DBMS_OUTPUT.PUT_LINE('My PL/SQL Block Works');
END;
/