少年阿賓

          那些青春的歲月

            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
          主站蜘蛛池模板: 霍林郭勒市| 巫山县| 吴江市| 保德县| 三亚市| 观塘区| 腾冲县| 保康县| 山西省| 共和县| 耒阳市| 青岛市| 顺平县| 高安市| 惠水县| 和静县| 巨鹿县| 金坛市| 莱芜市| 分宜县| 江陵县| 开远市| 漳平市| 巨野县| 杨浦区| 桐乡市| 宁晋县| 精河县| 玛多县| 宁国市| 准格尔旗| 澎湖县| 云梦县| 天柱县| 大丰市| 民乐县| 齐齐哈尔市| 伊川县| 亚东县| 普宁市| 长子县|