PLSQL程序流程

 

IF语句结构:

   if(条件表达式)-

     -then-

     -执行语句;-

   -end;

 

IF-THEN-ELSE语句结构:

   if(条件表达式)-

    -then-

    -执行语句;-

-else-

-执行语句;-

   end;

 

ELSIF语句:

   if(条件表达式)-

    -then-

    -执行语句;-

-elsif-

-执行语句;-

-elsif-

-执行语句;-

-else-

-执行语句;-

   end;

注意:elsif语句是顺序执行的,各个执行条件之间是互斥的关系,在使用该语句是需要注意条件的顺序关系。

 

IF嵌套:

   if(条件表达式)-

-then-

 (-执行语句;-)

 If (条件表达式)-

   -then

   -执行语句;-

   -else-

   -执行语句;-

 end;

   -else-

    -then-

    -执行语句;-

   end;

 

CASE语句:

Case 的两种行为方式。

一,简单的case语句,case  选择器 when  xxx  then  xxx

二,搜索式  case  when xxx then xxx 这个是没有选择器的。

 

循环控制语句:

1.基本循环机构:

  loop

执行语句

  end loop;

2.While循环:

  while vars<=12 loop

执行语句;

  end loop;

3.for循环:

  for i in 1..10 loop

执行语句;

  end loop;

  i1-10循环执行

 

中断控制

exit 退出 ②exit when(先执行在判断)

顺序控制

continue 继续 ②continue when(先执行在判断)

 

NULL语句:

 Null是一种判断语句,在流程控制中,意味着什么也不做

 If name=’sun’

  then

   dbms_output.put_line(‘name=’||name);

  else

   null;--

   Null起到了屏蔽异常的作用,不需要处理异常的场合就可以使用null不做任何事情。

 end;

posted @ 2017-01-23 11:26  爱潜水的小八  阅读(266)  评论(0编辑  收藏  举报