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;