oracle控制语句学习二——case流程控制语句
来源:互联网 发布:楚楚街和淘宝哪个好 编辑:程序博客网 时间:2024/05/22 06:10
declarev_community_type_name communitytype.name%type;beginselect c.name into v_community_type_name from communitytype cwhere c.community_type_id = '&community_type_id';casewhen v_community_type_name = '电子图书'then dbms_output.put_line('查询到电子图书');when v_community_type_name = '新书快读'then dbms_output.put_line('查询到新书快读');elsedbms_output.put_line('查询到其他资源库');end case;end;
case when 也可用于查询语句
select casewhen id is null and parent_id is nullthen 'yzhnykxyjs'when id is null and parent_id is not nullthen parent_idelse idend id,casewhen id is null and parent_id is nullthen (select com.name from community com where com.community_id = 'yzhnykxyjs')when id is null and parent_id is not nullthen (select com.name from community com where com.community_id = parent_id)else (select col.name from collection col where col.collection_id = id)end name,casewhen id is null and parent_id is nullthen '0'when id is null and parent_id is not nullthen 'yzhnykxyjs'else parent_idend parent_id,casewhen id is null and parent_id is nullthen 'community'when id is null and parent_id is not nullthen 'zsk'else 'collection'end object_type,countfrom(select cc.collection_id id,count(1) count,cc.community_id parent_idfrom community comjoin community2community c2c on c2c.community_id = com.community_id and c2c.parent_community_id = 'yzhnykxyjs'join community2collection cc on cc.community_id = c2c.community_idjoin collection col on col.collection_id = cc.collection_id and col.withdrawn = 'N'join collection2item c2i on c2i.collection_id = col.collection_idjoin item i on i.item_id = c2i.item_id and i.withdrawn = 'N'where not exists (select 1 from community2institution c2i where c2i.community_id = com.community_id)and com.withdrawn = 'N'group by rollup(cc.community_id,cc.collection_id)) allcom
输出如下:
1qt_2934参加会议情况qtcollection3
2qt_2935实验室活动记事qtcollection2
3qt_2936无法归类却有必要保存qtcollection3
4qt其它yzhnykxyjszsk8
5cgk_2529发明专利cgkcollection27
6cgk_2530科技成果cgkcollection23
7cgk_2727图书著作cgkcollection10
8cgk_3328品种库cgkcollection5
9cgk成果库yzhnykxyjszsk65
10xmk_2729项目经费xmkcollection1
11xmk_2730在研项目xmkcollection5
12xmk_2926完成项目xmkcollection17
13xmk项目库yzhnykxyjszsk23
14jxgz_2531教学课件jxgzcollection1
15jxgz教学工作yzhnykxyjszsk1
16shfw_2928农业推广shfwcollection1
17shfw_2929企业合作shfwcollection1
18shfw社会服务yzhnykxyjszsk2
19xslw_2472期刊论文xslwcollection254
20xslw_2526会议论文xslwcollection17
21xslw_2527学位论文xslwcollection32
22xslw_3597jkljklxslwcollection1
23xslw学术论文yzhnykxyjszsk304
24xspy_2533硕士研究生xspycollection6
25xspy_2534博士研究生xspycollection6
26xspy_2535博士后xspycollection2
27xspy学生培养yzhnykxyjszsk14
28jssrcsml_2930中文书刊jssrcsmlcollection1
29jssrcsml教师私人藏书目录yzhnykxyjszsk1
30yzhnykxyjs浙江大学原子核农业科学研究所0community418
0 0
- oracle控制语句学习二——case流程控制语句
- Oracle:PL/SQL--流程控制(二)——case语句(注意:在Oracle 9i 后引入)
- PHP流程控制语句-swith...case语句
- Oracle 流程控制语句
- Oracle流程控制语句
- 流程控制的使用CASE 语句用法
- shell编程-流程控制-case语句
- C#—流程控制语句
- 【C#】流程控制语句—循环语句
- 【C#】流程控制语句—跳转语句
- oracle控制语句学习
- java流程控制语句(二)
- JAVA基础再回首(二)——流程控制语句、跳转控制语句
- 流程语句控制语句
- MySQL高级二——流程控制语句
- Linux下C语言学习(二)——流程控制语句和数组的学习
- java基础(二)----流程控制语句跳转控制语句
- pl/sql学习8——流程控制语句
- unity3d 中使用Profiler看到的一项"WaitForTargetFPS"费资源过高的原因
- 圆柱体
- oracle控制语句学习一——if elsif else控制语句
- 线段树-两道题
- java IO 管道流学习记录
- oracle控制语句学习二——case流程控制语句
- oracle控制语句学习三——loop 循环控制语句
- oracle经典sql语句
- 数学之路-分布式计算-numpy在centos下的安装
- oracle控制语句学习四——while循环控制语句、for循环控制语句 递增 递减、嵌套循环和标号
- Go语言设计模式实践:迭代器(Iterator)
- oracle复合数据类型学习五——pl/sql记录
- 玩具javascript:cookie管理
- Oracle 10g数据库闪回知识