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