Determine if a user is ordering an SP business--Stored procedures

Source: Internet
Author: 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
--To determine whether the user ordered an SP business, ordered to return yes, otherwise 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;
---take 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
--the process exits automatically after an exception is thrown
Raise My_region_err;
End If;
--Take 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);
--Take the order relationship
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;

Determine if a user is ordering an SP business--Stored procedures

Related Article

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.