我有一个场景,我想在下面的过程中添加IF ELSE
条件:
我尝试过以下但是没有编译
PROCEDURE VSAT_EXCEL_REPORT
(
P_R4GSTATE IN NVARCHAR2,
TBLDATA OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN TBLDATA FOR
IF P_R4GSTATE = "ALL"
THEN
SELECT ENB.SAP_ID AS SAP_ID,CAND.CANDIDATEID AS CANDIDATE_ID,ENB.R4G_STATE AS STATE,ENB.SITE_TYPE AS SITE_TYPE,CAND.SITENAME AS SITE_NAME
,ENB.SITEID AS SITEID,ENB.PRIORITY_SITE AS PRIORITYSITE,ENB.CIRCLE AS CIRCLE,
DECODE (VTS.STATUS_NAME, null, 'Fill VSAT form', VTS.STATUS_NAME) AS STATUS,
ENB.LATITUDE
,ENB.LONGITUDE
,VT.SITE_DETAILS_TECHNOLOGY
,VT.SITE_DETAILS_MOUNT_TYPE
,VT.SITE_DETAILS_ANTENNA_SIZE
,VT.SITE_DETAILS_AMSL
,VT.SITE_DETAILS_PLATFORM_REQUIRED
,VT.SITE_DETAILS_PLATFORM_HEIGHT
,VT.SITE_DETAILS_ROOFTOP_SITE
,VT.SITE_DETAILS_NOOFLOORS
,VT.SITE_DETAILS_ADD_ROOFTOP_SITE
,VT.SITE_DETAILS_STRUCTURAL_STAB
,VT.SITE_DETAILS_HEIGHT_OF_ANTENNA
,VT.SITE_DETAILS_SATELLITE_BAND
,VT.ANTENNA_DISTANCE_NEAR_AIRPORT
,VT.ANTENNA_AIRPORT_NAME
,VT.GSAT_LOS_16_55E
,VT.GSAT_LOS_18_74E
,VT.GSAT_LOS_12_83E
FROM R4G_OSP.ENODEB ENB
INNER JOIN R4G_OSP.CANDIDATE CAND ON ENB.SAP_ID = CAND.SAP_ID
LEFT JOIN TBL_VSAT_MST_DETAIL VT ON ENB.SAP_ID = VT.SAP_ID
LEFT JOIN TBL_VSAT_STATUS_MST VTS ON VT.STATUS_ID = VTS.STATUS_ID
WHERE ENB.SCOPE = 'EnodeB-Connected_MW'
AND ENB.SITEBACKHAUL = 'MW'
AND CAND.STATUS = 'Fill Vendor Survey Form'
AND UPPER(STATE) IN
(SELECT REGEXP_SUBSTR(UPPER(P_R4GSTATE),'[^,]+', 1, LEVEL) AS RFIELDS FROM DUAL
CONNECT BY REGEXP_SUBSTR(UPPER(P_R4GSTATE), '[^,]+', 1, LEVEL) IS NOT NULL);
ELSE
--Some condtion
END VSAT_EXCEL_REPORT;
答案 0 :(得分:2)
我认为应该是这样的形象:
procedure VSAT_EXCEL_REPORT
(
P_R4GSTATE in nvarchar2,
TBLDATA out sys_refcursor
) as
begin
if P_R4GSTATE = 'ALL' then
open TBLDATA for
select ENB.SAP_ID as SAP_ID
,CAND.CANDIDATEID as CANDIDATE_ID
,ENB.R4G_STATE as STATE
,ENB.SITE_TYPE as SITE_TYPE
,CAND.SITENAME as SITE_NAME
,ENB.SITEID as SITEID
,ENB.PRIORITY_SITE as PRIORITYSITE
,ENB.CIRCLE as CIRCLE
,DECODE(VTS.STATUS_NAME
,null
,'Fill VSAT form'
,VTS.STATUS_NAME) as STATUS
,ENB.LATITUDE
,ENB.LONGITUDE
,VT.SITE_DETAILS_TECHNOLOGY
,VT.SITE_DETAILS_MOUNT_TYPE
,VT.SITE_DETAILS_ANTENNA_SIZE
,VT.SITE_DETAILS_AMSL
,VT.SITE_DETAILS_PLATFORM_REQUIRED
,VT.SITE_DETAILS_PLATFORM_HEIGHT
,VT.SITE_DETAILS_ROOFTOP_SITE
,VT.SITE_DETAILS_NOOFLOORS
,VT.SITE_DETAILS_ADD_ROOFTOP_SITE
,VT.SITE_DETAILS_STRUCTURAL_STAB
,VT.SITE_DETAILS_HEIGHT_OF_ANTENNA
,VT.SITE_DETAILS_SATELLITE_BAND
,VT.ANTENNA_DISTANCE_NEAR_AIRPORT
,VT.ANTENNA_AIRPORT_NAME
,VT.GSAT_LOS_16_55E
,VT.GSAT_LOS_18_74E
,VT.GSAT_LOS_12_83E
from R4G_OSP.ENODEB ENB
inner join R4G_OSP.CANDIDATE CAND
on ENB.SAP_ID = CAND.SAP_ID
left join TBL_VSAT_MST_DETAIL VT
on ENB.SAP_ID = VT.SAP_ID
left join TBL_VSAT_STATUS_MST VTS
on VT.STATUS_ID = VTS.STATUS_ID
where ENB.SCOPE = 'EnodeB-Connected_MW'
and ENB.SITEBACKHAUL = 'MW'
and CAND.STATUS = 'Fill Vendor Survey Form'
and
UPPER(STATE) in
(select REGEXP_SUBSTR(UPPER(P_R4GSTATE), '[^,]+', 1, level) as RFIELDS
from DUAL
connect by REGEXP_SUBSTR(UPPER(P_R4GSTATE), '[^,]+', 1, level) is not null);
else
open TBLDATA for
select * from dual;
end if;
end VSAT_EXCEL_REPORT;