CREATE OR REPLACE  PACKAGE WWW --建立包www
as
   type  tmp_cursor is  ref cursor; --定义游标tmp_cursor
   procedure readrecd(rowx integer,tmp_cursor1 out tmp_cursor);
end;
/create or replace package body www --建立包体www
as
   procedure readrecd(rowx integer,tmp_cursor1 out tmp_cursor)
   is
       deltmpsql varchar2(2000);
   begin
       deltmpsql:='delete tmp_emp';//tmp_emp是一个已经事先建立好的临时表
        execute immediate deltmpsql ;  --清理临时表
        insert into tmp_emp select * from emp; --向临时表写入数据
        open tmp_cursor1 for  select rownum as rowno,ename,job from tmp_emp where rownum<=rowx;     --提取数据到tmpx
        execute immediate deltmpsql ;  --清理临时表
   end;
end;
/连接名称为kkk,如何调用上面这个包www.readrecd(参数1,参数2,参数3)

解决方案 »

  1.   

    你的连接是指database link吗,
    在过程后面加上link就可以了。
    给你一个参考:首先进行适当授权:
    [oracle@jumper oracle]$ sqlplus "/ as sysdba" SQL*Plus: Release 9.2.0.4.0 - Production on Tue Nov 7 21:07:56 2006Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning option
    JServer Release 9.2.0.4.0 - ProductionSQL> grant create public database link to eygle;Grant succeeded.
    SQL> grant all on dbms_flashback to eygle;Grant succeeded.
    建立DB Link:
    SQL> connect eygle/eygle
    Connected.
    SQL> create public database link hsbill using 'hsbill'; Database link created.SQL> select db_link from dba_db_links;DB_LINK
    ---------------------------------------------------
    HSBILLSQL> select * from dual@hsbill;D
    -
    X
    此后可以尝试使用DB Link进行远程和本地执行:SQL> set serveroutput on
    SQL> set feedback off
    SQL> declare
    2 r_gname varchar2(40);
    3 l_gname varchar2(40);
    4 begin
    5 execute immediate
    6 'select GLOBAL_NAME from global_name@hsbill' into r_gname;
    7 dbms_output.put_line('gname of remote:'||r_gname);
    8 select GLOBAL_NAME into l_gname from global_name;
    9 dbms_output.put_line('gname of locald:'||l_gname);
    10 end;
    11 /
    gname of remote:HSBILL.HURRAY.COM.CN
    gname of locald:EYGLE远程Package或Function调用也可以随之实现:SQL> declare
    2 r_scn number;
    3 l_scn number;
    4 begin
    5 execute immediate
    6 'select dbms_flashback.GET_SYSTEM_CHANGE_NUMBER@hsbill from dual' into r_scn;
    7 dbms_output.put_line('scn of remote:'||r_scn);
    8 end;
    9 /
    scn of remote:18992092687SQL> -The End-