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:
- </Pre> <pre name = "code" class = "plain"> IF condition THEN
- Statements;
- [ELSIF condition
- THEN statements;]
- [ELSE statements;]
- 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
- DECLARE • x number (2): = 5;
- Y number (2): = NULL;
- BEGIN
- IF x! = Y THEN
- Dbms_output.put_line (100 );
- ELSE
- Dbms_output.put_line (200 );
- End if;
- 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.
- DECLARE
- X number (2): = null;
- Y number (2): = null;
- Begin
- If x! = Y then
- Dbms_output.put_line (100 );
- Else
- Dbms_output.put_line (200 );
- End if;
- End;
-
-
-
- DECLARE
- X number (2): = null;
- Y number (2): = null;
- Begin
- If x = y then
- Dbms_output.put_line (100 );
- Else
- Dbms_output.put_line (200 );
- End if;
- End;
Output 200
- DECLARE
- X number (2): = 5;
- Y number (2): = null;
- Begin
- If nvl (x, 0 )! = Nvl (y, 0) then
- Dbms_output.put_line (100 );
- Else
- Dbms_output.put_line (200 );
- End if;
- End;
100 output
Logical table: