少年阿賓

          那些青春的歲月

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks
          有倆種方法:
          一種是聲明系統游標,一種是聲明自定義游標,然后后面操作一樣,參數類型為
          in out 或out
          (1)聲明個人系統游標.(推薦)
          create or replace p_temp_procedure
          (
              cur_arg out sys_refcursor;     --方法1
          )
          begin
              open cur_arg for select * from tablename;
          end
          調用
          declare
              cur_calling sys_refcursor;
          begin
              p_temp_procedure(cur_calling);  --這樣這個游標就有值了
              for rec_next in cur_calling loop
               ....
              end loop;
          end;










          create or replace procedure getList(id in varchar2,mycur out sys_refcursor)
          is
          v_sql varchar2(4000);
          begin
          dbms_output.put_line('call it success');
          v_sql:='select * from userbean s where s.id=:1';
          open mycur for v_sql using id;
          commit;
          end;



          create or replace procedure my_procedure
          (mypageNo number,mypageSize number,myInfo_Cursor out sys_refcursor)
          as
          pageNO number;
          pageSize number;

          begin
          open myInfo_Cursor for
          select * from product
          where pid between 1 + (pageNo - 1) * pageSize and 4 + (pageNo - 1) * pageSize;

          end;




          declare
          my_cursor sys_refcursor;
          begin
          my_procedure(1,2,my_cursor);
          for rec_next in my_cursor loop
          dbms_output.put_line('pid:'||rec_next.pid||'  ptypeid:'||rec_next.ptypeid||'  proname:'||rec_next.proname||'  price:'||rec_next.price||'  pronum:'||rec_next.pronum);
          end loop;
          end;
          posted on 2012-09-06 23:30 abin 閱讀(397) 評論(0)  編輯  收藏 所屬分類: oracle
          主站蜘蛛池模板: 高尔夫| 清水河县| 华坪县| 永平县| 通江县| 老河口市| 沧源| 宁城县| 正镶白旗| 科技| 分宜县| 巴林左旗| 襄垣县| 淳化县| 榆林市| 屏山县| 张家界市| 景宁| 达州市| 玉山县| 汾阳市| 富顺县| 遂平县| 汉寿县| 兴业县| 邯郸县| 姚安县| 二连浩特市| 德格县| 北宁市| 监利县| 敦煌市| 淳安县| 临沂市| 黔江区| 威信县| 南部县| 贡嘎县| 屏东县| 永善县| 凯里市|