Oracle 过程为 IF ELSE 语句给出语法错误

问题描述 投票:0回答:1

下面是给出错误的程序

错误(5718,1):PLS-00103:在预期以下情况之一时遇到符号“ELSE”:

PROCEDURE GET_FTTX_DATA_BY_MZ_FL
(
  PUSERTYPE IN NVARCHAR2,
  POPERATIONTYPE IN NVARCHAR2,
  PSPANTYPE IN NVARCHAR2,
  PMAINTZONECODE IN VARCHAR2,  
  PSPANDATA OUT SYS_REFCURSOR
)

AS
SQLSTM   VARCHAR2 (2000);
BEGIN 
    IF PSPANTYPE = 'FTTX'  AND POPERATIONTYPE = 'New' THEN
               BEGIN
                    OPEN PSPANDATA FOR
                     
                    SELECT JB.FSA_ID AS FSA_ID,JB.MAINTENANCEZONECODE,JBP.JOB_PROGRESS_ID AS REQ_ID,JB.REOFFERFLAG,
                        MODIFIED_BY AS LAST_UPDATE_BY,SM.STATUS_NAME,
                        TO_DATE(SYSDATE) - TO_DATE(JBP.UMS_GROUP_ASS_TO_DATE) AS PENDING_DAYS
                        FROM TBL_FIBER_INV_JOBS JB
                        INNER JOIN TBL_FIBER_INV_JOB_PROGRESS JBP ON JB.JOB_ID = JBP.JOB_ID
                        INNER JOIN TBL_FIBER_INV_STATUS_MASTER SM ON JBP.STATUS_ID = SM.STATUS_ID
                        WHERE JB.MAINTENANCEZONECODE = PMAINTZONECODE                      
                        AND UMS_GROUP_ASS_TO_NAME NOT IN ('Construction_Engineer','NHQ-PMO')
                   --     AND JBP.APPROVED_BY IS NULL
                        AND JBP.JOB_PROGRESS_FLAG = 0
                       -- AND JBP.APPROV_REJECT_REMARK IS NULL
                        AND JB.SPAN_TYPE= 'FTTX'              
                        AND JBP.APPROVED_BY IS NULL
                        ORDER BY JBP.JOB_PROGRESS_ID DESC;            
                        
ELSE PSPANTYPE = 'FTTX'  AND POPERATIONTYPE = 'Partial' THEN    

          BEGIN                
                
                OPEN PSPANDATA FOR
                     
                    SELECT JB.FSA_ID AS FSA_ID,JB.MAINTENANCEZONECODE,JBP.JOB_PROGRESS_ID AS REQ_ID,JB.REOFFERFLAG,
                        MODIFIED_BY AS LAST_UPDATE_BY,SM.STATUS_NAME,
                        TO_DATE(SYSDATE) - TO_DATE(JBP.UMS_GROUP_ASS_TO_DATE) AS PENDING_DAYS
                        FROM TBL_FIBER_INV_JOBS JB
                        INNER JOIN TBL_FIBER_INV_JOB_PROGRESS JBP ON JB.JOB_ID = JBP.JOB_ID
                        INNER JOIN TBL_FIBER_INV_STATUS_MASTER SM ON JBP.STATUS_ID = SM.STATUS_ID
                        WHERE JB.MAINTENANCEZONECODE = PMAINTZONECODE                      
                        AND UMS_GROUP_ASS_TO_NAME NOT IN ('Construction_Engineer','NHQ-PMO')
                   --     AND JBP.APPROVED_BY IS NULL
                        AND JBP.JOB_PROGRESS_FLAG = 0
                       -- AND JBP.APPROV_REJECT_REMARK IS NULL
                        AND JB.SPAN_TYPE= 'FTTX'     
                        AND JBP.APPROVED_BY IS NULL OR AND JBP.REJECTED_BY IS NULL
                        ORDER BY JBP.JOB_PROGRESS_ID DESC;   
                
          END;   
END;          
   END IF;   
       --  END IF;     
--END;
END GET_FTTX_DATA_BY_MZ_FL;

oracle stored-procedures
1个回答
0
投票

在 IF PSPANTYPE = 'FTTX' AND POPERATIONTYPE = 'New' THEN 之后,您打开了新的 pl/sql 块,发出 BEGIN 命令,但该块有 END; ELSE 部分中的命令。在 ELSE 部分中,您还打开了一个新的 pl/sql 块,该块已关闭,但有两个 END;一个接一个的命令是行不通的。
当你开始一个区块时,你必须正确地结束; it - 在 if 部分中打开的块必须在同一 if 部分中关闭,而不是在其他地方...

© www.soinside.com 2019 - 2024. All rights reserved.