CREATE OR REPLACE PACKAGE pkg_test
AS
   TYPE myrctype IS REF CURSOR;
END pkg_test;
/create PROCEDURE get(p_age NUMBER, p_rc OUT pkg_test.myrctype)
   IS
      sqlstr   VARCHAR2 (500);
   BEGIN
     sqlstr:='select id,name,sex,address,postcode,birthday
           from student where age='||p_age;
         OPEN p_rc FOR sqlstr;
END get;

解决方案 »

  1.   

    declare
    w_rc pkg_test.myrctype;
    w_id       student.id%type;
      w_name     student.name%type;
      w_sex      student.sex%type;
      w_address  student.address%type;
      w_postcode student.postcode%type;
      w_birthday student.birthday%type;
    begin
    get('1',w_rc);
    loop
     fetch w_rc into w_id,w_name,w_sex,w_address,w_postcode,w_birthday;
     exit when w_rc%notfound;
     dbms_output.put_line(w_name);
     end loop;
    end;
    /
      

  2.   

    你好!按照你所教方法,我在sql*plus worksheet中执行了一段代码,提示:pl/sql过程已成功完成。但是我又如何看到记录集中的返回值呢?我通过print语句想显示查询结果,但提示有错。请问要实现这一功能该怎么办?
      

  3.   

    beckhambobo(beckham):这样建立的存储过程,界面调用得到的数据显示出来时,要一条一条取吗?也就是说界面显示这个结果集时该怎么处理?