简体   繁体   English

PLS-00103:预期以下情况之一时遇到符号“ TEST_PKG”:

[英]PLS-00103: Encountered the symbol “TEST_PKG” when expecting one of the following: ;

I am getting this error 我收到此错误

Errors: check compiler log 6/3 PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:language 错误:检查编译器日志6/3 PLS-00103:预期以下情况之一时遇到符号“ BEGIN”:语言

17/1 PLS-00103: Encountered the symbol "PROCEDURE" when expecting one of the following: 17/1 PLS-00103:预期以下情况之一时遇到符号“ PROCEDURE”:

end not pragma final instantiable order overriding static member constructor map The symbol "static" was substituted for "PROCEDURE" to continue. end not pragma最终实例化顺序覆盖静态成员构造函数映射将符号“ static”替换为“ PROCEDURE”以继续。

27/5 PLS-00103: Encountered the symbol "TEST_PKG" when expecting one of the following: 27/5 PLS-00103:在预期以下情况之一时遇到符号“ TEST_PKG”:

;. ;。

Please anyone can help. 请任何人都可以帮助。

SET serveroutput ON SIZE 10000;
CREATE OR REPLACE PACKAGE test_pkg
AS
  FUNCTION test_item_fcn(item_name in varchar2) 
     RETURN BOOLEAN
     AS
  BEGIN
  for c1 in (select * from test_item_ref where test_item_ref.item_id = item_name and rownum = 1) loop
    res := true;
    exit; -- only care about one record, so exit.
  end loop;
  return( res );
  EXCEPTION
     WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM, 1, 200));
  END test_item_fcn;

PROCEDURE test_PROC1(p_string IN VARCHAR2) 
  AS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('Output: ' || TO_CHAR(test_item_fcn(p_string)));

  EXCEPTION
     WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM, 1, 200));
  END test_PROC1;

END test_pkg;
/
SHOW ERRORS;

Oracle packages contsist of 2 parts - PACKAGE and PACKAGE BODY . 2份Oracle包contsist - PACKAGEPACKAGE BODY You should define only functions/procedures headers in the PACKAGE . 您应该仅在PACKAGE定义函数/过程标头。 And the PACKAGE BODY will contain implementation. 并且PACKAGE BODY将包含实现。

So your code is more like PACKAGE BODY specification - just use CREATE OR REPLACE PACKAGE BODY test_pkg . 因此,您的代码更像是PACKAGE BODY规范-只需使用CREATE OR REPLACE PACKAGE BODY test_pkg

But before that - create PACKAGE specification like below: 但在此之前-创建如下的PACKAGE规范:

CREATE OR REPLACE PACKAGE test_pkg
AS
  FUNCTION test_item_fcn(item_name in varchar2) 
     RETURN BOOLEAN;

  PROCEDURE test_PROC1(p_string IN VARCHAR2);

END test_pkg;
/


CREATE OR REPLACE PACKAGE BODY test_pkg
AS
  FUNCTION test_item_fcn(item_name in varchar2) 
     RETURN BOOLEAN
     AS
  BEGIN
  for c1 in (select * from test_item_ref where test_item_ref.item_id = item_name and rownum = 1) loop
    res := true;
    exit; -- only care about one record, so exit.
  end loop;
  return( res );
  EXCEPTION
     WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM, 1, 200));
  END test_item_fcn;

PROCEDURE test_PROC1(p_string IN VARCHAR2) 
  AS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('Output: ' || TO_CHAR(test_item_fcn(p_string)));

  EXCEPTION
     WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM, 1, 200));
  END test_PROC1;

END test_pkg;
/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:PLS-00103:在预期以下情况之一时遇到符号“ AS”:返回 - Error: PLS-00103: Encountered the symbol “AS” when expecting one of the following:return PLS-00103:在FlyWay中遇到符号“文件结尾” - PLS-00103: Encountered the symbol “end-of-file” in FlyWay PLS-00103:遇到符号“文件结束” - PLS-00103: Encountered the symbol “end-of-file” 使用Netbeans时出现此错误pls 103103 - I'm getting this error pls 00103 when using netbeans Mockitio-在单元测试中期望模拟时返回null - Mockitio - returning null when expecting mock in unit test 当测试期望异常时,assertEquals不会显示错误 - assertEquals doesn't show errors when the test is expecting exceptions 在prepareCall后遇到符号\\"CLOSE\\" - Encountered the symbol \"CLOSE\" after prepareCall 尝试使用 Firebase 合并 Google SignIn 时遇到错误“无法解析符号 'mGoogleSignInClient'” - I encountered the error “Cannot resolve symbol 'mGoogleSignInClient'” when trying to incorporate Google SignIn using Firebase 用春豆测试的预期结果 - Expecting result in test with spring bean 当我构建 maven 单元测试时,出现以下错误 - When I was building a maven unit test, I got the following error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM