Which statement is true about the execution of the above code?

Examine the following code:


Which statement is true about the execution of the above code?
A. It executes and displays null.
B. It executes and the condition returns true.
C. It executes and control goes to the else statement.
D. It fails because no value is assigned to the v_myage variable.

Download Printable PDF. VALID exam to help you PASS.

One thought on “Which statement is true about the execution of the above code?

  1. I also think correct answer is C.
    Below quotes and test code confirms it.

    https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements005.htm

    “To test for nulls, use only the comparison conditions IS NULL and IS NOT NULL. If you use any other condition with nulls and the result depends on the value of the null, then the result is UNKNOWN.”
    “A condition that evaluates to UNKNOWN acts almost like FALSE. For example, a SELECT statement with a condition in the WHERE clause that evaluates to UNKNOWN returns no rows. However, a condition evaluating to UNKNOWN differs from FALSE in that further operations on an UNKNOWN condition evaluation will evaluate to UNKNOWN. Thus, NOT FALSE evaluates to TRUE, but NOT UNKNOWN evaluates to UNKNOWN.”

    set serveroutput on;
    declare
    v_myage number;
    begin
    if v_myage<11 then
    dbms_output.put_line(' I am a child ');
    else
    dbms_output.put_line(' I am not a child ');
    end if;
    end;
    /

    I am not a child

Leave a Reply

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


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