直接写
select YourFunctionName(......) into YourVariable from dual;
就可以

解决方案 »

  1.   

    CREATE OR REPLACE PACKAGE pkg_test
    AS
       TYPE myrctype IS REF CURSOR;
    END pkg_test;
    /CREATE PROCEDURE get (p_id NUMBER, p_rc OUT pkg_test.myrctype)
       IS
          sqlstr   VARCHAR2 (500);
       BEGIN
          IF p_id = 0 THEN
             OPEN p_rc FOR
                SELECT ID, NAME, sex, address, postcode, birthday
                  FROM student;
          ELSE
             sqlstr :=
                'select id,name,sex,address,postcode,birthday
               from student where id=:w_id';
             OPEN p_rc FOR sqlstr USING p_id;
          END IF;
       END get;
    /declare
    v_rc pkg_test.myrctype;
    begin
    get('11',v_rc);
    fetch v_rc into 变量1,变量2,...;
    loop
    exit when v_rc%notfound;
    dbms_output.put_line(变量1||' '||变量2||'...);
    fetch v_rc into 变量1,变量2,...;
    end loop;
    end;
    /