PLS-00103:在期望以下之一时遇到符号“end-of-file”::=(@%;

PLS-00103: Encountered the symbol “end-of-file” when expecting one of the following: :=(@%;

我正在尝试动态执行一个存储过程,因为我根据一个简单的数字获得了很多存储过程,所以我创建了另一个过程来执行此操作,但我的问题标题一直出现错误,在这里我的程序是:

PROCEDURE P_EXEC_REG(p_Register IN VARCHAR2, p_LineBuff IN VARCHAR2, p_User IN VARCHAR2) IS  

  l_Procedure   VARCHAR2(50);
  l_Sentence    VARCHAR2(500);

BEGIN    
  l_Procedure := 'P_REG_' || TRIM(p_Register);
  l_Sentence := 'BEGIN CTS.PK_INTEGRATE_MANIFESTO.' || l_Procedure || '(:A, :B); END;';
  EXECUTE IMMEDIATE l_Sentence
  USING IN p_LineBuff, p_User;    
END;

因为我们有数百个过程,用 if 语句来做它很痛苦,希望有人能帮我解决这个问题,另外,我会告诉你我是如何调用它的:

PROCEDURE P_LOAD_FILE(p_Linebuff IN VARCHAR2, p_User IN VARCHAR2) IS

l_Register        VARCHAR2(3);

BEGIN
    BEGIN
       SELECT SUBSTR(p_Linebuff,1,3)
       INTO   l_Register
       FROM   DUAL;                 
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
            --p_result := false;
            NULL;
    END;
    CTS.PK_INTEGRATE_MANIFESTO.P_EXEC_REG(l_Register, p_Linebuff, p_User);

    EXCEPTION
      WHEN OTHERS THEN
      NULL;         
END;

谢谢你们,感谢@John Heller 的评论,我找到了这个问题的答案,使用该命令我可以注意到它实际上正在执行,但是当我发送动态参数时,isl_Register,我没有检查 null 值,所以它直接执行 EXECUTE IMMEDIATE,最后带有一个 null 参数的过程。现在看起来像这样:

PROCEDURE P_LOAD_FILE(p_Linebuff IN VARCHAR2, p_User IN VARCHAR2, p_Error OUT BOOLEAN, p_Message OUT VARCHAR2) IS

  l_MessageLevel    NUMBER(1);
  l_Register        VARCHAR2(3);
  l_Command         VARCHAR2(50);
  l_Procedure       VARCHAR2(4000);
  l_Error           NUMBER(1);

  BEGIN              

  IF p_Linebuff IS NOT NULL OR p_Linebuff <> '' THEN
        BEGIN
           SELECT SUBSTR(p_Linebuff,1,3)
           INTO   l_Register
           FROM   DUAL;

           IF LENGTH(TRIM(l_Register)) = 3 THEN
              P_EXEC_REG(l_Register, p_Linebuff, p_User, l_Error, p_Message);
           END IF;               
        EXCEPTION
             WHEN NO_DATA_FOUND THEN
                NULL;
        END;
    END IF;

  EXCEPTION
  WHEN OTHERS THEN
      p_Error := TRUE;
      p_Message := 'Sucedio un error al procesar el archivo.';      
  END;

感谢您的帮助,如果这是一个愚蠢的问题,我们深表歉意:)