此处显示的过程抛出错误:
错误(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;
最佳实践是在发布之前通过删除不相关的部分来简化代码。 在您的情况下,只有主要
BEGIN
END
块是相关的。通过用简单的例子替换条件和语句,你会得到
BEGIN
IF true THEN
BEGIN
NULL;
ELSE true THEN
BEGIN
NULL;
END;
END;
END IF;
END;
这显然是错误的,只有你知道如何修复它。
在 IF PSPANTYPE = 'FTTX' AND POPERATIONTYPE = 'New' THEN 之后,您打开了新的 pl/sql 块,发出 BEGIN 命令,但该块有 END; ELSE 部分中的命令。在 ELSE 部分中,您还打开了一个新的 pl/sql 块,该块已关闭,但有两个 END;一个接一个的命令是行不通的。
当你开始一个区块时,你必须正确地结束;它 - 在 if 部分中打开的块必须在同一 if 部分中关闭,而不是在其他地方...您根本不需要打开新块(阅读代码中的注释)
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 <--- delete this row (Begin without End)
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 <--- delete this row (Begin with TWO Ends)
--
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 -- is this OR or AND ???
ORDER BY JBP.JOB_PROGRESS_ID DESC;
--
--END; <--- delete this row (2 consecutive Ends)
--END; <--- delete this row (2 consecutive Ends)
--
END IF;
-- END IF;
--END;
END GET_FTTX_DATA_BY_MZ_FL;
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) := '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,
SYSDATE - TO_DATE(JBP.UMS_GROUP_ASS_TO_DATE, ''yyyy-mm-dd'') AS PENDING_DAYS -- add your own format mask - this is just an example
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.JOB_PROGRESS_FLAG = 0
AND JB.SPAN_TYPE= ''FTTX''
';
BEGIN
IF PSPANTYPE = 'FTTX' AND POPERATIONTYPE = 'New' THEN
OPEN PSPANDATA FOR
SQLSTM || ' AND JBP.APPROVED_BY IS NULL ORDER BY JBP.JOB_PROGRESS_ID DESC';
ELSE PSPANTYPE = 'FTTX' AND POPERATIONTYPE = 'Partial' THEN
OPEN PSPANDATA FOR
SQLSTM || ' AND ( JBP.APPROVED_BY IS NULL OR JBP.REJECTED_BY IS NULL ) ORDER BY JBP.JOB_PROGRESS_ID DESC';
END IF;
END GET_FTTX_DATA_BY_MZ_FL;