Oracle case when

Source: Internet
Author: User

1. Standard (the end of a case is an end case, but the end can also be used. 2 is, but the end cannot be used directly in 1, and an error will be reported)

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 directly at the end. It should not work in theory, but this can be used.

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;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.