加入收藏 | 设为首页 | 会员中心 | 我要投稿 济南站长网 (https://www.0531zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

详解Oracle数据库各类控制语句的使用

发布时间:2016-11-27 20:06:16 所属栏目:大数据 来源:站长网
导读:Oracle数据库各类控制语句的使用是本文我们主要要介绍的内容,包括一些逻辑控制语句、Case when的使用、While的使用以及For的使用等等,接下来我们就开始一一介绍这部分内容,希望能够对您有所帮助。 Oracle 中逻辑控制语句nbsp; If elsif else end if set

Oracle数据库各类控制语句的使用是本文我们主要要介绍的内容,包括一些逻辑控制语句、Case when的使用、While的使用以及For的使用等等,接下来我们就开始一一介绍这部分内容,希望能够对您有所帮助。

Oracle 中逻辑控制语句nbsp;

If elsif else end if  
set serverout on;  
declare per_dep_count number;  
begin  
select count(*) into per_dep_count from emp;  
if per_dep_countgt;0 then  
dbms_output.put_line('Big Than 0');  
elsif per_dep_countgt;5 then lt;span style="font-size:24px;color:#ff0000;"gt;lt;stronggt;--elsif not elseif!!!!   
lt;/stronggt;lt;/spangt;        dbms_output.put_line('Big Than 5');  
else  
dbms_output.put_line('En#63;');  
end if;  
end; 

nbsp;Case when 的使用的两种方式nbsp; :

第一种使用方式

declare per_dep_count number;  
begin  
select count(*) into per_dep_count from emp;  
case per_dep_count  
when 1 then  
dbms_output.put_line('1');  
when 2 then  
dbms_output.put_line('2');  
else  
dbms_output.put_line('else');  
end case;  
end;  

第二种使用方式

declare per_dep_count number;  
begin  
select count(*) into per_dep_count from emp;  
case   
when per_dep_count=1 then  
dbms_output.put_line('1');  
when per_dep_count=2 then  
dbms_output.put_line('2');  
else  
dbms_output.put_line('else');  
end case;  
end;  

While 的使用nbsp;

declare v_id number:=0;  
begin  
while v_idlt;5 loop  
v_idv_id:=v_id+1;  
dbms_output.put_line(v_id);  
end loop;  
end;  

For的使用nbsp;

declare v_id number:=0;  
begin  
for v_id in 1..5 loop  
dbms_output.put_line(v_id);  
end loop;  
end; 

关于Oracle数据库各类控制语句的使用就介绍到这里了,希望本次的介绍能够对您有所收获!

(编辑:济南站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!