Which line(s) in the above code are NOT valid?

Examine the following partial declare section from a block of PL/SQL code


Which line(s) in the above code are NOT valid? (Choose all that apply.)
A. line 2
B. line 3
C. line 4
D. line 5

Download Printable PDF. VALID exam to help you PASS.

4 thoughts on “Which line(s) in the above code are NOT valid?

  1. DB version 12.2.0.1.0

    Following block executes successfully:

    declare
    v_wage number := 1000;
    v_total_wages v_wage%type;
    work_complete constant boolean:=true;
    all_work_complete work_complete%type;
    begin
    null;
    end;

    correct answer ONLY B

  2. If we execute following statement then we get errors:

    declare
    v_wage number not null:=1000;
    v_total_wages v_wage%type;
    work_complete constant boolean:=true;
    all_work_complete work_complete%type;
    begin
    null;
    end;
    /

    ERROR at line 3:
    ORA-06550: line 3, column 15:
    PLS-00218: a variable declared NOT NULL must have an initialization assignment
    ORA-06550: line 5, column 19:
    PLS-00206: %TYPE must be applied to a variable, column, field or attribute, not to “WORK_COMPLETE”
    ORA-06550: line 5, column 19:
    PL/SQL: Item ignored

    It fails on 3rd line because we need to assign value to variable v_total_wages which inherits not null
    attribute from v_wage.
    It fails on 5th line because “The %TYPE attribute lets you declare a constant, variable, collection element, record field, or subprogram parameter to be of the same data type as a previously declared variable or column (without knowing what that type is).” So constant work_complete can be referencing item, but not referenced item.

    https://docs.oracle.com/en/database/oracle/oracle-database/12.2/lnpls/TYPE-attribute.html#GUID-EAB44F7E-B2AB-4AC6-B83D-B586193D75FC

    Following rewritten block executes successfully:

    declare
    v_wage number not null:=1000;
    v_total_wages v_wage%type:=500;
    work_complete boolean:=true;
    all_work_complete work_complete%type;
    begin
    null;
    end;
    /

    PL/SQL procedure successfully completed.

    1. The code works with 12.2, I am assuming you ran it in 11g and it differs? so since this certification is depended on 11g the answer will be B & D is it?

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.