Control Structure of Oracle -- PLSQL

Source: Internet
Author: User

Condition branch statement•IF statement:-IF-THEN-END IF-IF-THEN-ELSE-END IF-IF-THEN-ELSIF-END IF-Case statement:• Cyclic statements-Loop
Syntax:

  1. </Pre> <pre name = "code" class = "plain"> IF condition THEN
  2. Statements;
  3. [ELSIF condition
  4. THEN statements;]
  5. [ELSE statements;]
  6. End if;
Condition is a Boolean variable or expression (values: TRUE, FALSE, or NULL) (executed only when the expression is TRUE
After THEN ).
 
THEN is a clause that is associated with the previous Boolean expression.
 
Statements is a number of PL/SQL or SQL statements (the statement may contain nested IF statements ).
The keyword ELSIF will introduce a Boolean expression (if the first condition returns FALSE or NULL, The ELSEIF key
Characters will lead to additional selection conditions ).
 
IF the IF condition is not true, the statement following the ELSE keyword is executed.

For more information about Oracle, see Oracle topics page http://www.bkjia.com/topicnews.aspx? Tid = 12
 

NULL Processing
  1. DECLARE • x number (2): = 5;
  2. Y number (2): = NULL;
  3. BEGIN
  4. IF x! = Y THEN
  5. Dbms_output.put_line (100 );
  6. ELSE
  7. Dbms_output.put_line (200 );
  8. End if;
  9. END;
The result of any arithmetic expression containing null values is null.
 
If the variable value is null, the return value of is null is true.
 
Null variables can be used as null strings to connect to expressions.
  1. DECLARE
  2. X number (2): = null;
  3. Y number (2): = null;
  4. Begin
  5. If x! = Y then
  6. Dbms_output.put_line (100 );
  7. Else
  8. Dbms_output.put_line (200 );
  9. End if;
  10. End;
  11. DECLARE
  12. X number (2): = null;
  13. Y number (2): = null;
  14. Begin
  15. If x = y then
  16. Dbms_output.put_line (100 );
  17. Else
  18. Dbms_output.put_line (200 );
  19. End if;
  20. End;
Output 200
  1. DECLARE
  2. X number (2): = 5;
  3. Y number (2): = null;
  4. Begin
  5. If nvl (x, 0 )! = Nvl (y, 0) then
  6. Dbms_output.put_line (100 );
  7. Else
  8. Dbms_output.put_line (200 );
  9. End if;
  10. End;

100 output
Logical table:
  • 1
  • 2
  • Next Page

Related Article

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.