oracle if 和 case语句的使用
来源:互联网 发布:h5dm新域名 编辑:程序博客网 时间:2024/05/17 09:38
oracle if语句和case语句的使用例子
set serveroutput on
declare
v_n1 number(2):=-9;begin
if v_n1=0 then
dbms_output.put_line('这个值是0');
elsif v_n1=1 then
dbms_output.put_line('这个值是1');
elsif v_n1=2 then
dbms_output.put_line('这个值是2');
else
if v_n1<0 then
dbms_output.put_line('是一个负数');
else
dbms_output.put_line('是一个正数');
end if;
end if;
end;
---------------------case-------------------------------------
declare
v_date date:=to_date('2017-05-13 12:14:15','YYYY-MM-DD HH24:MI:SS');
v_c varchar2(20);
BEGIN
v_c:=to_char(v_date,'d');
case v_c
when '1' then
DBMS_OUTPUT.PUT_LINE('Today is Sunday');
when '2' then
DBMS_OUTPUT.PUT_LINE('Today is Monday');
when '3' then
DBMS_OUTPUT.PUT_LINE('Today is Tuesday');
when '4' then
DBMS_OUTPUT.PUT_LINE('Today is Wendesday');
when '5' then
DBMS_OUTPUT.PUT_LINE('Today is Thursday');
when '6' then
DBMS_OUTPUT.PUT_LINE('Today is Friday');
else
DBMS_OUTPUT.PUT_LINE('Today is Saturday');
end case;
END;
--第二种写法
declare
v_course number;
v_list varchar2(100);
begin
select a into v_course from a;
case
when v_course >=90 then v_list:='A';
when v_course >=80 then v_list:='B';
when v_course >=70 then v_list:='C';
when v_course >=60 then v_list:='D';
else v_list:='F';
end case;
DBMS_OUTPUT.PUT_LINE(v_list);
end;
- oracle if 和 case语句的使用
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- MySQL的if,case语句使用总结
- Oracle IF & CASE语句
- Oracle IF语句的使用
- oracle if 语句的使用
- MySQL中的if和case语句使用总结
- MySQL中的if和case语句使用总结
- MySQL的if,case语句使用总结..MySql 里的IFNULL、NULLIF和ISNULL用法
- HDU 3339
- IOS 初识WebRTC之webrtc的源码下载和编译
- Spring Boot中@Controller和@restController的区别
- jquery + ajax + json入门实例
- 在Spring中复制粘贴项目
- oracle if 和 case语句的使用
- grafana弱口令检测
- Unity中Input.GetAxis方法的返回值含义
- mysql去除重复记录
- 在Linux中让echo命令显示带颜色的字
- JDBC中事务的使用
- 应急资源管理系统方案
- .NET日期类型序列化后返回前台格式转换问题
- 写给java web一年左右工作经验的人