用pl/sql打开,然后编译,再打开一个命令窗口输入exec 过程名

解决方案 »

  1.   

    能给出一段使用代码吗?pl/sql学习中
      

  2.   

    给你个具体的例子,create or replace package pkg_test
    as
      type myCursor is ref cursor;
      function get(p_id number) return myCursor;
    end pkg_test;create or replace package body pkg_test 
    as
      --输入ID 返回记录集的函数
      function get(p_id number) return myCursor is
         rc myCursor;
         strsql varchar2(200);
      begin
         if p_id=0 then 
            open rc for select czyxm from cw_czyglb ;  
         else
            strsql:='select czyxm from cw_czyglb';
            open rc for strsql ;
         end if;
         return rc;  
         end get;
    end pkg_test;
    --上面是一个返回结果集的函数,下面调用.
    create or replace procedure pro_test as
        v_out pkg_test.myCursor;
        v_name varchar2(100);
    begin
        v_out:=pkg_test.get(0);  --得到结果集
        loop
            fetch v_out into v_name;
            exit when v_out%notfound;
            dbms_output.putline(v_name);
        end loop;
    end;