PL/SQL学习(二)条件和循环语句

 
 
PLSQL条件语句
IF THEN ELSE STATEMENT
1)
IF condition
THEN
 statement 1;
ELSE
 statement 2;
END IF;
 
2)
IF condition 1
THEN
 statement 1;
 statement 2;
ELSIF condtion2 THEN
 statement 3;
ELSE
 statement 4;
END IF
3)
IF condition 1
THEN
 statement 1;
 statement 2;
ELSIF condtion2 THEN
 statement 3;
ELSE
 statement 4;
END IF;
 
4)
IF condition1 THEN
ELSE
 IF condition2 THEN
 statement1;
 END IF;
ELSIF condition3 THEN
  statement2;
END IF;
 
CASE语句
  1)
    CASE selector
     WHEN expression1 THEN operation1
     WHEN expression2 THEN operation2
      ...
     WHEN expressionN THEN operationN
     ELSE default_operation
    END CASE;
  2)
    CASE
     WHEN condition1 THEN operation1
     WHEN condition2 THEN operation2
      ...
     WHEN conditionN THEN operationN
     ELSE default_operation
    END CASE;
 

PLSQL循环语句
简单一般循环(相当于do while循环)
LOOP
statements;
EXIT;
{or EXIT WHEN condition;}
END LOOP;
 
While循环
WHILE <condition>
LOOP statements;
END LOOP;
 
For循环
FOR counter IN val1..val2
LOOP statements;
END LOOP;
posted @ 2016-09-06 16:14  JillWen  阅读(1383)  评论(0编辑  收藏  举报