RT,求一个oracle存储过程
使用游标的,最好有输入输出,

解决方案 »

  1.   

    呵呵,在我的blog上有写这个问题。里面也有代码和讲解有时间你可以去看看,对你应该有帮助,因为写的很多,不方便写在这里面http://user.qzone.qq.com/67622728
      

  2.   

    大哥哥,你那叫例子吗
    I 服了 you
      

  3.   

    create   or   replace   procedure   sp_test(p_date   in   varchar2)   is 
    type   t_cursor   is   ref   cursor; 
    v_str   varchar(1000); 
    v_cur   t_cursor; 
    r_cur   计量点表码表200701%rowtype; 
    begin 
      v_str   :=   'select   *   from   计量点表码表 '||p_date|| '   '; 
      open   v_cur   for   v_str; 
      loop 
      Fetch   v_cur   into   r_cur; 
      exit   when   v_cur%notfound; 
      dbms_output.put_line( 'the   result   is:   '||r_cur.计量点编码|| '   '||r_cur.费率类型); 
      end   loop; 
      close   v_cur; 
    end   sp_test; 
      

  4.   

    declare   @name   varchar(20) declare   t_cursor   cursor   for   
    select   name   from   syscolumns   
    where   id=object_id( 'test1 ')   and   colid> 1   order   by   colid open   t_cursor fetch   next   from   t_cursor   into   @name while   @@fetch_status=0 
    begin 
            exec( 'select   '+@name+ '   as   t   into   test3   from   test1 ') 
            set   @s= 'insert   into   test2   select   ' ' '+@name+ ' ' ' ' 
            select   @s=@s+ ', ' ' '+rtrim(t)+ ' ' ' '   from   test3 
            exec(@s) 
            exec( 'drop   table   test3 ') 
            fetch   next   from   t_cursor   into   @name 
    end 
    close   t_cursor 
    deallocate   t_cursor