创建oracle包遇到PLS-00103:遇到符号“CREATE”

前端之家收集整理的这篇文章主要介绍了创建oracle包遇到PLS-00103:遇到符号“CREATE”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Oracle sql开发者编写oracle包,我得到这个编译错误

Error(7,1): PLS-00103: Encountered the symbol “CREATE” .

create or replace
PACKAGE TestPackage AS 
 FUNCTION beforePopulate RETURN BOOLEAN;
 FUNCTION afterPopulate RETURN BOOLEAN;
END TestPackage;

CREATE OR REPLACE PACKAGE BODY TestPackage AS
   FUNCTION beforePopulate RETURN BOOLEAN AS
   BEGIN
      DELETE FROM TEST_1;
      INSERT INTO TEST_1
      SELECT * FROM TEST WHERE VALUE=300;
      COMMIT;
      RETURN TRUE;
     EXCEPTION
       WHEN OTHERS THEN
        RETURN FALSE;
   END;
   FUNCTION afterPopulate RETURN BOOLEAN AS
     BEGIN
         UPDATE TEST SET RESULT="completed" WHERE VALUE=300;
            COMMIT;
         RETURN TRUE;
         EXCEPTION
           WHEN OTHERS RETURN FALSE;
        END;
  END;
END TestPackage;

如果我添加/在第6行,错误变成:

Error(6,1): PLS-00103: Encountered the symbol “/”

我厌倦了这样一个空的实现:

create or replace 
package package1 as 
END PACKAGE1;

CREATE OR REPLACE 
package body package1 as 
end package1;

我得到了同样的错误

当你有BEGIN,END等等你在PL / sql,而不是sql

需要在行的开头处使用单个(“前进”)斜杠终止PL / sql块。这告诉Oracle,你完成了你的PL / sql块,所以它编译这个文本块。

SQL查询 – 以分号结尾:

update orders set status = 'COMPLETE' where order_id = 55255;

PL / sql块 – 以分号分隔的命令,块由forward-slash终止:

create or replace procedure mark_order_complete (completed_order_id in number)
is
begin
     update orders set status = 'COMPLETE' where order_id = :completed_order_id;
end mark_order_complete;
/

猜你在找的Oracle相关文章