Apex 4.2
我在下面有以下pl / sql代码块,但无论何时我在APex中运行它,我都会收到错误:
ORA-06550:第35行,第4栏:PLS-00103:遇到符号“;”期待以下之一:if
DECLARE
show_changes BOOLEAN;
l_exists INTEGER;
BEGIN
Select count(*) into l_exists
From dba_role_privs
where grantee = upper(:APP_USER) and
(granted_role = 'SURVEY_JOB_SUID' or granted_role = 'SURVEY_SUID');
IF l_exists = 0 THEN /* unauthorized */
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND (:P32_SUBMISSION_DATE IS NULL AND :P32_LOCK_DATE IS NULL) THEN
show_changes := TRUE;
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND (:P32_SUBMISSION_DATE IS NOT NULL AND :P32_LOCK_DATE IS NULL) THEN
show_changes := TRUE;
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND (:P32_SUBMISSION_DATE IS NOT NULL AND :P32_LOCK_DATE IS NOT NULL) THEN
show_changes := FALSE;
END IF;
ELSE /* authorized */
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND (:P32_SUBMISSION_DATE IS NULL AND :P32_LOCK_DATE IS NULL) THEN
show_changes := TRUE;
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND (:P32_SUBMISSION_DATE IS NOT NULL AND :P32_LOCK_DATE IS NULL) THEN
show_changes := TRUE;
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND (:P32_SUBMISSION_DATE IS NOT NULL AND :P32_LOCK_DATE IS NOT NULL) THEN
show_changes := TRUE;
END IF;
Return show_changes;
END;
我不确定问题是什么。任何帮助将不胜感激。提前谢谢。
答案 0 :(得分:3)
IF
始终必须与END IF
配对,ELSE
位于END IF
之前。如果您希望在外部IF
的两个分支中的每个分支中都有三个单独的IF
语句,则需要类似
IF l_exists = 0
THEN
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND
(:P32_SUBMISSION_DATE IS NULL AND :P32_LOCK_DATE IS NULL)
THEN
show_changes := TRUE;
END IF;
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND
(:P32_SUBMISSION_DATE IS NOT NULL AND :P32_LOCK_DATE IS NULL)
THEN
show_changes := TRUE;
END IF;
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND
(:P32_SUBMISSION_DATE IS NOT NULL AND :P32_LOCK_DATE IS NOT NULL)
THEN
show_changes := FALSE;
END IF;
ELSE
<<repeat the pattern>>
END IF;
但我的猜测是,你真的不希望在每个分支中有三个单独的IF
语句。我猜你想要一个IF
ELSIF
语句
IF l_exists = 0
THEN
IF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND
(:P32_SUBMISSION_DATE IS NULL AND :P32_LOCK_DATE IS NULL)
THEN
show_changes := TRUE;
ELSIF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND
(:P32_SUBMISSION_DATE IS NOT NULL AND :P32_LOCK_DATE IS NULL)
THEN
show_changes := TRUE;
ELSIF :P32_SURVEY_JOB_REQUEST_ID IS NOT NULL AND
(:P32_SUBMISSION_DATE IS NOT NULL AND :P32_LOCK_DATE IS NOT NULL)
THEN
show_changes := FALSE;
END IF;
ELSE
<<repeat the pattern>>
END IF;