PLS-00103:预期以下其中一项时遇到符号“ IS”::= @%;不是null范围的默认字符

问题描述

我遇到此错误

private void setJavadoc(final BodyDeclaration bodyDeclaration,final CommentEntry commentEntry) {
    final Javadoc javadoc = (Javadoc) ASTNode.copySubtree(ast,commentEntry.getComment());
    final TagElement tagElement = ast.newTagElement();
    final TextElement textElement = ast.newTextElement();
    textElement.setText(commentEntry.getText());
    tagElement.fragments().add(textElement);
    javadoc.tags().add(tagElement);
    bodyDeclaration.setJavadoc(javadoc);
}

我的包裹是:

LINE/COL ERROR
-------- -----------------------------------------------------------------
4/11     pls-00103: Encountered the symbol "IS" when expecting one of the
         following:
         := . ( @ % ; not null range default character

解决方法

  • 不是CRUSOR,而是CURSOR
  • 光标不能包含INSERT语句;这是一个SELECT
  • 您正在检查游标是否返回了某些内容,但是-您从未打开过它也未从中获取过它,所以它几乎没有用
  • insert_error似乎在插入行时出错,但是-如果光标没有返回任何内容,您实际上是在提高它

基本上,您根本不需要游标。这样的过程可以做到:

   PROCEDURE insert_tr (p_empno  emp_20171250.empno%TYPE,p_ename  emp_20171250.ename%TYPE,p_sal    emp_20171250.sal%TYPE)
   IS
   BEGIN
         INSERT INTO emp_20171250 (empno,ename,sal)
              VALUES (p_empno,p_ename,p_sal);
   END insert_tr;

如果insert失败,Oracle仍将引发异常-是的,您可以根据需要对其进行处理。

另外,最好区分参数名称和列名称。例如,在他们的名字前加上p_(就像我一样)。