0

顶点 4.2

我在下面有以下 pl/sql 代码块,但是每当我在 APex 中运行它时,我都会不断收到错误消息:

ORA-06550:第 35 行,第 4 列:PLS-00103:遇到符号“;” 预期以下情况之一时:如果

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;

我不确定问题是什么。任何帮助将不胜感激。提前致谢。

4

1 回答 1

3

AnIF总是必须与 an 配对,END IF并且 theELSE出现在 之前END IF。如果您想IF在 external 的两个分支中的每个分支中包含三个单独的语句,则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;
于 2013-08-23T18:31:10.627 回答