无码视频在线观看,99人妻,国产午夜视频,久久久久国产一级毛片高清版新婚

  • 始創(chuàng)于2000年 股票代碼:831685
    咨詢熱線:0371-60135900 注冊有禮 登錄
    • 掛牌上市企業(yè)
    • 60秒人工響應
    • 99.99%連通率
    • 7*24h人工
    • 故障100倍補償
    全部產品
    您的位置: 網(wǎng)站首頁 > 幫助中心>文章內容

    Oracle帶游標的存儲過程在plus中的調用實例

    發(fā)布時間:  2012/9/5 17:08:13

    之前在帖子 http://www.linuxidc.com/Linux/2012-07/65117.htm 里回答了一些網(wǎng)友的關于怎么穿件一個返回記錄集合的存儲過程。想必很多網(wǎng)友已經很明白了,這里就不多講了。

    怎么調用含游標的存儲過程在sqlplus

    Oracle怎么執(zhí)行帶游標的過程?-
     


    給你一個例子


    --游標使用(游標其實是一個放入內存臨時表)
    declare
       money cms3_simcard.card_fee%type :=0; --定義與表字段相同類型
       cursor mycursor is --定義游標
              select * from cms3_simcard
              where return_flag = 1 and msisdn like '138%';
       my_record mycursor%rowtype;  --定義游標記錄類型
       Counter int :=0;
      
    begin
       open mycursor;  --打開游標
       if mycursor%isopen  then  --判斷打開成功
       loop --循環(huán)獲取記錄集
         fetch mycursor into my_record; --獲取游標中的記錄
             if mycursor%found then  --游標的found屬性判斷是否有記錄
                dbms_output.put_line(my_record.card_fee);
             else
                exit;
             end if;
       end loop;
       else
         dbms_output.put_line('游標沒有打開');
       end if;
      close mycursor;
    end;
    如果你要問我程序里怎么調用 那你就不要問了 因為那個太多知道了 很少有人問到。 廢話不多說 上實例了

    首先看下t1的表結構

    SQL> desc T1  
     名稱                                      是否為空? 類型  
     ----------------------------------------- -------- ---------------------   
      
     D                                         NOT NULL DATE  
     A                                                  NUMBER(38)  
     B                                                  NUMBER(38)  
     C                                                  NUMBER(38) 
    看下T1的表里的數(shù)據(jù)情況

    SQL> select * from t1;  
      
    D                       A          B          C  
    -------------- ---------- ---------- ----------   
    12-3月 -11            102         21         15  
    14-3月 -11            100         58         73  
    15-3月 -11            105                    87 
    和上一個帖子一樣 首先創(chuàng)建一個包先

    SQL> create or replace package pkg_package  
      2  as  
      3      type type_cursor is ref cursor;  
      4      type type_record is record  
      5      (  
      6          test01 DATE,  
      7          test02 NUMBER(38),  
      8          test03 NUMBER(38) ,  
      9          test04 NUMBER(38)  
     10      );  
     11  end;  
     12  /  
      
    程序包已創(chuàng)建。 
    創(chuàng)建一個帶游標的的存儲過程也就是一個返回記錄集合的存儲過程

    SQL> create or replace procedure p_temp_procedure  
      2  (  
      3      cur_out_arg out pkg_package.type_cursor  
      4  )  
      5  is  
      6  begin  
      7      open cur_out_arg for select * from T1;  
      8  end;  
      9  /  
      
    過程已創(chuàng)建。 
    該有的數(shù)據(jù)都有了,接著重點來了。  調用存儲過程返回記錄集合

    SQL> declare  
      2      cur_out_arg pkg_package.type_cursor;  
      3      rec_arg pkg_package.type_record;  
      4  begin  
      5      dbms_output.put_line('------------------------');  
      6      p_temp_procedure(cur_out_arg);  
      7      loop  
      8          fetch cur_out_arg into rec_arg;  
      9         exit when cur_out_arg%notfound;  
     10         dbms_output.put_line(rec_arg.test01||' '||rec_arg.test02||' '||rec_a  
    rg.test03||''||rec_arg.test04);  
     11      end loop;  
     12  end;  
     13  /  
    ------------------------   
    12-3月 -11 102 2115  
    14-3月 -11 100 5873  
    15-3月 -11 105 87  
      
    PL/SQL 過程已成功完成。  
      
    SQL> 


    本文出自:億恩科技【mszdt.com】

    服務器租用/服務器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質保障!--億恩科技[ENKJ.COM]

  • 您可能在找
  • 億恩北京公司:
  • 經營性ICP/ISP證:京B2-20150015
  • 億恩鄭州公司:
  • 經營性ICP/ISP/IDC證:豫B1.B2-20060070
  • 億恩南昌公司:
  • 經營性ICP/ISP證:贛B2-20080012
  • 服務器/云主機 24小時售后服務電話:0371-60135900
  • 虛擬主機/智能建站 24小時售后服務電話:0371-60135900
  • 專注服務器托管17年
    掃掃關注-微信公眾號
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 億恩科技 版權所有  地址:鄭州市高新區(qū)翠竹街1號總部企業(yè)基地億恩大廈  法律顧問:河南亞太人律師事務所郝建鋒、杜慧月律師   京公網(wǎng)安備41019702002023號
      1
     
     
     
     

    0371-60135900
    7*24小時客服服務熱線