『ORACLE』 PLSQL—case语句(11g)
来源:互联网 发布:大数据安全需求分析 编辑:程序博客网 时间:2024/06/07 12:01
语法:
CASE selector
WHEN exp1 then res1
WHEN exp2 then res2
WHEN exp3 then res3
...
[ELSE resN]
end;
SQL> declare
2 mygrade char(1):='A';
3 res varchar2(20);
4 begin
5 res :=
6 CASE mygrade
7 WHEN 'A' THEN 'The mark is 90-100'
8 WHEN 'B' THEN 'The mark is 80-90'
9 WHEN 'C' THEN 'The mark is 70-80'
10 WHEN 'D' THEN 'The mark is 60-70'
11 WHEN 'E' THEN 'The mark is 0-60'
12 END;
13 dbms_output.put_line(res);
14 end;
15 /
The mark is 90-100
PL/SQL procedure successfully completed.
SQL> 2
2* mygrade char(1):='A';
SQL> ch /'A'/'F'/
2* mygrade char(1):='F';
SQL> l
1 declare
2 mygrade char(1):='F';
3 res varchar2(20);
4 begin
5 res :=
6 CASE mygrade
7 WHEN 'A' THEN 'The mark is 90-100'
8 WHEN 'B' THEN 'The mark is 80-90'
9 WHEN 'C' THEN 'The mark is 70-80'
10 WHEN 'D' THEN 'The mark is 60-70'
11 WHEN 'E' THEN 'The mark is 0-60'
12 END;
13 dbms_output.put_line(res);
14* end;
SQL> /
PL/SQL procedure successfully completed.
SQL> declare
2 mygrade char(1):='F';
3 res varchar2(20);
4 begin
5 res :=
6 CASE mygrade
7 WHEN 'A' THEN 'The mark is 90-100'
8 WHEN 'B' THEN 'The mark is 80-90'
9 WHEN 'C' THEN 'The mark is 70-80'
10 WHEN 'D' THEN 'The mark is 60-70'
11 WHEN 'E' THEN 'The mark is 0-60'
12 ELSE 'The mark is null'
13 END;
14 dbms_output.put_line(res);
15 end;
16 /
The mark is null
PL/SQL procedure successfully completed.
- 『ORACLE』 PLSQL—case语句(11g)
- 『ORACLE』 PLSQL条件控制语句(11g)
- 『ORACLE』 PLSQL—基本循环(11g)
- 『ORACLE』 PLSQL创建存储过程(11g)
- 『ORACLE』 PLSQL更新数据示例(11g)
- 『ORACLE』 PLSQL删除数据示例(11g)
- PLSQL总结——3.case语句
- 『ORACLE』 PLSQL动态游标的使用(11g)
- 『ORACLE』 PLSQL静态游标的使用(11g)
- oracle 11g配置plsql
- Oracle/PLSQL: Case Statement
- Oracle 11g XE & PLSQL Developer 9
- plsql 连接 64位 oracle 11g
- PLSQL Developer 连接Oracle 11g
- Oracle BPM 11g & Case Management
- oracle组件验证语句(11g)
- ORACLE—plsql创建触发器语句
- 『ORACLE』 SQL语句简单使用(一)(11g)
- 狼和羊的故事
- hihoCoder 1043 : 完全背包
- HDU 2027 统计元音
- mysql基础
- Intellij IDEA显示边侧栏maven等
- 『ORACLE』 PLSQL—case语句(11g)
- Qt5.7.0 mingw+qwtplot3D 编译
- Hibernate 缓存机制
- Intent(1)
- segment tree cf197D Xenia and Bit Operations
- 树莓派的购买
- Java 集合 之 Queue 和 Stack
- 『ORACLE』 PLSQL条件控制语句(11g)
- 用指针处理输入3个整数,按由小到大的顺序输出