0

现在挣扎了一个多小时......为什么不能编译?

Body 编译得很好:

create or replace package body "PKG_CUSTOMER" is

PROCEDURE Create_Customer
(  pr_customer_id  customer.Customer_id%type,
      pr_country customer.country%type,
      pr_first_name  customer.first_name%type,
      pr_last_name  customer.last_name%type, 
      pr_birth_date   customer.birth_date%type,
      pr_customer_type customer.customer_type%type,
      pr_address customer.address%type)

   IS
   BEGIN
      INSERT INTO customer (Customer_ID,Country,First_Name,Last_Name,Birth_Date,Customer_Type,Address)
         VALUES(pr_customer_id, pr_country, pr_first_name, pr_last_name, pr_birth_date, pr_customer_type, pr_address);
   END Create_Customer;


   PROCEDURE Delete_Customer(pr_customer_id   customer.customer_id%type) IS
   BEGIN
   DELETE FROM order_line WHERE fk1_order_id IN (SELECT order_id FROM placed_order WHERE fk1_customer_id = pr_customer_id);
   DELETE FROM placed_order WHERE fk1_customer_id = pr_customer_id;
   DELETE FROM customer WHERE customer_id = pr_customer_id;
   END Delete_Customer;


end "PKG_CUSTOMER";​

但规范不会编译:

create or replace package PKG_CUSTOMER as

Procedure CREATE_CUSTOMER;
Procedure DELETE_CUSTOMER;

end;​

我收到此错误:

Compilation failed,line 3 (21:20:46)
PLS-00323: subprogram or cursor 'CREATE_CUSTOMER' is declared in a package specification and must be defined in the package bodyCompilation failed,line 4 (21:20:46)
PLS-00323: subprogram or cursor 'DELETE_CUSTOMER' is declared in a package specification and must be defined in the package body

我正在使用 Oracle APEX。

4

1 回答 1

5

包规范必须为您要公开的过程提供完整的规范。这包括参数。假设你想让你在包中声明的两个过程都对包外的调用者可用

create or replace package PKG_CUSTOMER 
as
  Procedure CREATE_CUSTOMER(  
        pr_customer_id  customer.Customer_id%type,
        pr_country customer.country%type,
        pr_first_name  customer.first_name%type,
        pr_last_name  customer.last_name%type, 
        pr_birth_date   customer.birth_date%type,
        pr_customer_type customer.customer_type%type,
        pr_address customer.address%type);
  Procedure DELETE_CUSTOMER(pr_customer_id   customer.customer_id%type);
end;​

如果您的意图是声明一个CREATE_CUSTOMER和一个DELETE_CUSTOMER每个都接受 0 个参数的过程,那么您还需要在包主体中实现这些过程。

于 2013-03-14T21:26:55.547 回答