判斷使用者是否定購某sp業務——預存程序

來源:互聯網
上載者:User

標籤:

create or replace procedure pro_check_sp(v_servnumber in varchar2,
                                         v_spid       in varchar2,
                                         v_spbizid    in varchar2,
                                         v_result     out varchar2
                                       
                                         ) is
  --判斷使用者是否定購某sp業務,已訂購返回yes,否則為no
  n_region  number(5);
  n_subsid  number(18);
  int_count number(10);
  my_region_err exception;
  my_subsid_err exception;
begin
  v_result  := ‘‘;
  int_count := 0;
  ---取region;
  SELECT DISTINCT REGION
    INTO n_region
    FROM TBCS.REC_SERVNUMBER_REGION
   WHERE BEGINNUM <= v_servnumber
     AND ENDNUM >= v_servnumber;
  if (n_region is null) then
    --拋出異常後過程會自動結束
    raise my_region_err;
  end if;
  --取subsid
  select count(*)
    into int_count
    from (select subsid
             from tbcs.subscriber
            where servnumber = v_servnumber
              and region = n_region
              and active = 1
           union
           select subsid
             from tbcs.subscriber
            where servnumber = v_servnumber
              and region = n_region
              and active = 1);
  if int_count != 1 then
    raise my_subsid_err;
  end if;
  select subsid
    into n_subsid
    from (select subsid
             from tbcs.subscriber
            where servnumber = v_servnumber
              and region = n_region
              and active = 1
           union
           select subsid
             from [email protected]_B.HEBEI.MOBILE.COM
            where servnumber = v_servnumber
              and region = n_region
              and active = 1);
  --取定購關係
  int_count := 0;
  select count(*)
    into int_count
    from (select t.*
             from tbcs.subs_spservice t
            where t.subsid = n_subsid
              and t.region = n_region
              and t.spid = v_spid
              and t.spbizid = v_spbizid
              and (t.enddate >= sysdate or t.enddate is null)
           union
           select t.*
             from [email protected]_B.HEBEI.MOBILE.COM t
            where t.subsid = n_subsid
              and t.region = n_region
              and t.spid = v_spid
              and t.spbizid = v_spbizid
              and (t.enddate >= sysdate or t.enddate is null));
  if int_count >= 1 then
    v_result := ‘yes‘;
  else
    v_result := ‘no‘;
  end if;
exception
  when my_region_err then
    v_result := ‘region_err‘;
  when my_subsid_err then
    v_result := ‘subsid_err‘;
 
end pro_check_sp;

判斷使用者是否定購某sp業務——預存程序

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.