比如包头和包体分别是如下:
包头
create or replace package pk1
as
procedure p1 (
pn in number default 100
);
function f1 return number;
end;
/
包体
create or replace package body pk1
as
procedure p1 (
pn in number default 100
)
as
begin
dbms_output.put_line(pn);
end; --end p1
function f1
return number
as
begin
return 1;
end; --end f1
end;
/
如何调用程序包的组件呢。。函数f1??
------解决方案--------------------
- SQL code
SQL> create or replace package pk1 as 2 procedure p1(pn in number default 100); 3 function f1 return number; 4 end; 5 / Package createdSQL> create or replace package body pk1 as 2 procedure p1(pn in number default 100) as 3 v_num number; 4 begin 5 v_num := f1; 6 dbms_output.put_line(v_num); 7 end; --end p1 8 9 function f1 return number as 10 begin 11 return 1; 12 end; --end f1 13 end; 14 / Package body createdSQL> select pk1.f1 from dual; F1---------- 1SQL> exec pk1.p1; 1 PL/SQL procedure successfully completed SQL>