详解Oracle数据库各类控制语句的使用
2015-09-02 00:00
786 查看
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?');
end if;
end;
Case when 的使用的两种方式 :
第一种使用方式
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数据库导入导出imp/exp
- Win8 安装64位Oracle11g R2
- oracle闪回(flashback)
- Oracle学习笔记20150901脏读不可重复读以及幻读概念理解
- Oracle 递归查询
- Oracle数据库修改字段长度
- 浅谈Oracle12c 数据库、用户、CDB与PDB之间的关系
- oracle查看表占用磁盘空间
- 关于Oracle GoldenGate 参数TRANLOGOPTIONS altarchivelogdest
- oracle快速复制表数据
- oracle11g dataguard安装实施
- oracle 学习sql
- Oracle数据库直连IO异常,更改localhost为本机IP地址后运行正常
- oracle OCCI编程
- ORACLE索引失效原因归纳[转]
- oracle 函数 WMSYS.WM_CONCAT 的用法 与 mysql 函数GROUP_CONCAT的用法
- 如何创建高效索引
- ORACLE:profile的管理
- oracle external table
- Linux系统下设置Oracle开机自动启动