数据库 
首页 > 数据库 > 浏览文章

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

(编辑:jimmy 日期: 2024/9/21 浏览:3 次 )

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

Oracle 中逻辑控制语句 

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_count>0 then  
dbms_output.put_line('Big Than 0');  
elsif per_dep_count>5 then <span style="font-size:24px;color:#ff0000;"><strong>--elsif not elseif!!!!   
</strong></span>        dbms_output.put_line('Big Than 5');  
else  
dbms_output.put_line('En"htmlcode">
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 的使用 

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

For的使用 

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

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

上一篇:Oracle SQL Developer连接报错(ORA-12505)的解决方案(两种)
下一篇:浅谈Oracle 11g 发行版2 新安装后关于登录的一些基本操作
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap