If else 语法

来源:互联网 发布:什么是yy语音软件 编辑:程序博客网 时间:2024/06/10 09:40
ORACLE存储过程中的ELSE IF语句怎么写,我这样写为何报错?应该怎么写?

IF(...) THEN
...
ELSE IF(...) THEN   
   ...
END IF  

 

正确写法为:

 

if ... then    
...   
elsif ... then
...   

else
...   
end if;   
    

   
if ... then     
  ...   
else
...   
end if;   
    
    
if ... then   --注意,没有begin
...   
end if;

 

 

还可以加上begin....end,本情况只适用于if 嵌套情况,如

if .... then

begin

 

end;

elsif ... then

begin

 

end if;

 

上面语句一般写成下面情况,同时,为了记忆方便,故任何情况最好不要加begin... end;

if .... then

 

else

   ...

 

end if;

原创粉丝点击