少年阿賓

          那些青春的歲月

            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 閱讀(394) 評論(0)  編輯  收藏 所屬分類: oracle
          主站蜘蛛池模板: 武清区| 桂林市| 文昌市| 龙口市| 同江市| 磐石市| 略阳县| 冕宁县| 呼和浩特市| 交口县| 东平县| 新疆| 康定县| 农安县| 淄博市| 商水县| 镇雄县| 华宁县| 工布江达县| 呼伦贝尔市| 黄平县| 陆河县| 汶川县| 铜梁县| 靖安县| 福安市| 岢岚县| 临潭县| 仁怀市| 乐平市| 太仆寺旗| 林芝县| 聊城市| 喀喇沁旗| 麻江县| 克什克腾旗| 黎平县| 尼勒克县| 日照市| 册亨县| 葵青区|