请问大家,定义创建成功,但包体出现:Warning: PACKAGE BODY created with compilation errors.为何???还有请问我如何调包并返回查询的结果集?
----------------------------------------------------------------------------------------
CREATE OR REPLACE PACKAGE pkg_BBB
AS
TYPE myrctype IS REF CURSOR;PROCEDURE get (p_id NUMBER, p_rc OUT myrctype);
END pkg_BBB;
/CREATE OR REPLACE PACKAGE BODY pkg_BBB
AS
PROCEDURE get (p_id NUMBER, p_rc OUT myrctype)
IS
qlstr VARCHAR2 (500);
BEGIN
sqlstr :='select ID1,AAA from BBB where id=:w_id';
OPEN p_rc FOR sqlstr USING p_id;
END pkg_BBB;

解决方案 »

  1.   

    Procedure get 也需要end
    在 end END pkg_BBB 上面
    写end get
      

  2.   

    CREATE OR REPLACE PACKAGE BODY pkg_BBB
    AS
    PROCEDURE get (p_id NUMBER, p_rc OUT myrctype)
    IS
    qlstr VARCHAR2 (500);
    BEGIN
    sqlstr :='select ID1,AAA from BBB where id=:w_id';
    OPEN p_rc FOR sqlstr USING p_id;
    end get;
    END pkg_BBB;-------------------
    还是这样呀
      

  3.   

    把procedure get 的名字换一下吧,叫getXxxx
      

  4.   

    还有你定义的变量写错了
    qlstr VARCHAR2 (500);
    应该是sqlsrt
      

  5.   

    还是老样子呀 CREATE OR REPLACE PACKAGE pkg_BBB
    AS
    TYPE myrctype IS REF CURSOR;PROCEDURE getid (p_id NUMBER, p_rc OUT myrctype);
    END pkg_BBB;
    /CREATE OR REPLACE PACKAGE BODY pkg_BBB
    AS
    PROCEDURE getid (p_id NUMBER, p_rc OUT myrctype)
    IS
    qlstr VARCHAR2 (500);
    BEGIN
    sqlstr :='select ID1,AAA from BBB where id=:w_id';
    OPEN p_rc FOR sqlstr USING p_id;
    end getid;
    END pkg_BBB;
      

  6.   

    还有你定义的变量写错了
    qlstr VARCHAR2 (500);
    应该是sqlsrt
    ------------
    好了??感谢zqz117(南瓜少爷)
    但如何调用返回查询的结果集?
      

  7.   

    给个范例给你看:create package pkg_test
    is
        type cur is ref cursor;
    end;
    create or replace function mytest return pkg_test.cur
    is 
        c pkg_test.cur;
    begin
        open c for select * from emp;
        return c;
    end;select mytest() from dual;mytest就返回记录的结果集
      

  8.   

    这是我的代码:在调用时就出错,请帮我查查???
    CREATE OR REPLACE PACKAGE pkg_BBB
    AS
    TYPE myrctype IS REF CURSOR;PROCEDURE getid (p_id NUMBER, p_rc OUT myrctype);
    END pkg_BBB;CREATE OR REPLACE PACKAGE BODY pkg_BBB
    AS
    PROCEDURE getid (p_id NUMBER, p_rc OUT myrctype)
    IS
    sqlstr VARCHAR2 (500);
    BEGIN
    sqlstr :='select ID1,AAA from BBB where id=:w_id';
    OPEN p_rc FOR sqlstr USING p_id;
    end getid;
    END pkg_BBB;declare
    cur pkg_BBB.myrctype;
    v_id BBB.ID1%type;
    v_aaa BBB.AAA%type;
    begin
    pkg_BBB.getid(1, cur);
    loop
    fetch cur into v_id, v_aaa;
    exit when cur%notfound;
    dbms_output.put_line(v_id || ' ' || v_aaa);
    end loop;
    close cur;
    end;