ORACLE存储过程的分支语法(IF语句)

基本语法

1.    if 条件 then 语句1;

       语句2;

       end if;

 

2.    if  条件 then 语句序列1;

       esle 语句序列;

       end if;

 

3.    if 条件 then 语句;

       elsif 语句 then 语句;

       else 语句;

       end if;

 

例:

declare
var number;
psal test_procedure.money%type;
begin

  select t.money 
  into psal 
  from test_procedure t 
  where t.name = 'XX天';

  if psal>1000 
    then var:=10;
  elsif psal>1999 
    then var:=20;
  else var:=20;

  end if;

dbms_output.put_line(var);

end;

唯一注意的一点就是elsif的写法!! 看清

楚!!

 


版权声明:本文为jiulanhao原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。