oracle case when

1.标准的(case结束是end case,但是用end也可以,2就是,可是1中不能直接用end,会报错)

if tmpmoshiid is not null then  
     CASE
     WHEN (main2.allcount<=100) THEN select t_0_100 into tmpkcbili from t_cl_moshi where id=tmpmoshiid;
     WHEN (main2.allcount<=1000) THEN select t_100_1000 into tmpkcbili from t_cl_moshi where id=tmpmoshiid;
     WHEN (main2.allcount<=5000) THEN select t_1000_5000 into tmpkcbili from t_cl_moshi where id=tmpmoshiid;
     WHEN (main2.allcount<=10000) THEN select t_5000_10000 into tmpkcbili from t_cl_moshi where id=tmpmoshiid;
     WHEN (main2.allcount<=20000) THEN select t_10000_20000 into tmpkcbili from t_cl_moshi where id=tmpmoshiid;
     ELSE
         tmpkcbili :=0;
     END case;
     select nvl(round(main2.allcount*tmpkcbili),0) into main2.kouchucnt from dual;
end if;


2.结束时直接end的,理论上应该不行的,但是这个可以用。

if Dianxin_V_Num>0 then
     tmpmsglevel := CASE
     WHEN (Dianxin_V_Num<=10) THEN 5
     WHEN (Dianxin_V_Num<=100) THEN 4
     WHEN (Dianxin_V_Num<=500) THEN 3
     WHEN (Dianxin_V_Num<=2000) THEN 2
     WHEN (Dianxin_V_Num>2000) THEN 1
     ELSE
     3
     END;
end if;


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值