详解Oracle数据库各类控制语句的使用
作者:lijiao 时间:2024-01-13 16:49:00
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,数据库,控制语句
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python插件机制实现详解
2021-08-28 06:55:30
![](https://img.aspxhome.com/file/2023/2/104832_0s.jpg)
Python挑选文件夹里宽大于300图片的方法
2023-08-13 11:35:19
python字典和JSON格式的转换方式
2022-02-01 14:27:05
![](https://img.aspxhome.com/file/2023/2/87812_0s.png)
编程活动中几个不良现象
2008-09-01 12:23:00
golang gorm框架数据库的连接操作示例
2024-01-21 06:52:56
python的类变量和成员变量用法实例教程
2023-10-26 01:09:58
python+requests接口压力测试500次,查看响应时间的实例
2021-09-29 08:27:56
![](https://img.aspxhome.com/file/2023/3/68373_0s.jpg)
简单的asp采集代码教程
2011-04-18 10:39:00
Python 读写文件和file对象的方法(推荐)
2022-01-09 08:36:03
python中的标准库html
2022-01-09 22:04:25
![](https://img.aspxhome.com/file/2023/0/121780_0s.png)
Python机器学习应用之决策树分类实例详解
2021-12-19 16:57:53
![](https://img.aspxhome.com/file/2023/3/103613_0s.png)
Python中Pyspider爬虫框架的基本使用详解
2021-04-01 06:00:31
![](https://img.aspxhome.com/file/2023/3/94053_0s.png)
sqlserver2005 行列转换实现方法
2024-01-14 01:34:56
如何实现优惠打折?
2010-06-03 10:27:00
vue.js 图片上传并预览及图片更换功能的实现代码
2024-05-09 15:23:47
![](https://img.aspxhome.com/file/2023/8/126428_0s.png)
Python入门教程(三十三)Python的字符串格式化
2023-04-03 11:58:17
![](https://img.aspxhome.com/file/2023/6/112736_0s.jpg)
详解Python爬虫爬取博客园问题列表所有的问题
2021-02-15 02:01:46
![](https://img.aspxhome.com/file/2023/8/109658_0s.jpg)
安装sql server 2008时的4个常见错误和解决方法
2024-01-22 10:24:58
![](https://img.aspxhome.com/file/2023/8/98018_0s.png)
CSS注意事项: 针对 Safari(WebKit)
2008-10-29 11:57:00
高性能WEB开发 web性能测试工具推荐
2022-06-09 00:29:59
![](https://img.aspxhome.com/file/2023/7/127207_0s.gif)