PL/SQL daily question: If condition containing null

Source: Internet
Author: User

WhichSome options will display "Hello Earth" after execution "?

(A) Declare l_total number; l_name varchar2 (10): = 'pl/SQL '; begin if l_name = 'pl/SQL 'or l_total> 100 then dbms_output.put_line ('Hello global'); else dbms_output.put_line ('Hello moon'); end if; end;/(B) declare l_total number; l_name varchar2 (10): = 'pl/SQL '; begin if l_total> 100 then dbms_output.put_line ('Hello Earth'); else dbms_output.put_line ('Hello moon '); end if; end;/(c) Declare l_total number; l_name varchar2 (10): = 'pl/SQL '; begin if l_total> 100 or l_total is null then dbms_output.put_line ('Hello global'); else dbms_output.put_line ('Hello moon '); end if; end;/(d) Declare l_total number; l_name varchar2 (10): = 'pl/SQL '; begin if nvl (l_total, 200)> 100 then dbms_output.put_line ('Hello global '); else dbms_output.put_line ('Hello moon '); end if; end ;/

Answer:Case: ACD


A: The uninitialized variable is null. The if condition is equivalent to if true or null. The preceding true will cause or to be ignored. The entire result is true.
B: The uninitialized variable is null, and the expression in the IF condition is evaluated as null,CodeWill go to Else.
C: If is null is used, and the result is true.
D: nvl converts null to 200 and returns true.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.