2013-03-14 53 views
0

挣扎了一个多小时......为什么不编译?包和程序编译

身体编译罚款:

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 。

+1

“The Body compiles fine:”你错了。如果未编译规范,程序包将无法编译。您收到的错误消息是由于过程签名与规范中的内容不匹配而导致主体不编译。 – APC 2013-03-14 21:33:07

+0

@APC我该如何解决这个问题? – 2013-03-14 21:35:28

+0

贾斯汀向你提供了答案。但神秘的是它不适合你。那么,谁可以告诉? – APC 2013-03-14 21:48:04

回答

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_CUSTOMERDELETE_CUSTOMER过程,每一个接受0参数,你会需要在包体中实现这些过程。

+0

嗨@Justin洞穴,我刚刚尝试过,我也遇到了同样的错误。我的意图是通过APEX应用程序通过它们的参数。 – 2013-03-14 21:29:39

+0

@IbrahiemRafiq - 你使用什么工具?你确定你是首先编译包装规格吗?然后编译包体? – 2013-03-14 21:37:10

+0

我使用的是ORACLE APEX,我确定你正在做这些事情。 – 2013-03-14 21:47:36