CREATE OR REPLACE PACKAGE BODY P_BODY
AS
 CURSOR lvMy IS SELECT * FROM TEST;

解决方案 »

  1.   

    declare cursor cursor_name is select * from table
    open cursor_name
    fetch cursor into file
    .....
    loop
    close cursor
      

  2.   

    create package test_age
    as
    type mycursor is ref cursor;
    end;
    /
    create procedure pro(p_rc out test_age.mycursor)
    as
    begin
    open p_rc for select * from table;
    end;
    /
      

  3.   

    在sql server中有个fetch_next方法,在orcale中有同样的方法吗??
      

  4.   

    declare 
     cursor cursor_name is select * from table;
     open cursor_name;
     fetch cursor into file;
     while cursor_name%FOUND then
      .....;
     fetch cursor into file;
    loop;
    close cursor;
      

  5.   

    楼上人兄,我按你的代码写了以下一段:
    set serveroutput ondeclare 
    vchcontent varchar2(500);
    begin
    declare 
     cursor cursor_name is select * from tu_smsvc_sub_mes;
     open cursor_name;
     fetch cursor into file;
     while cursor_name%FOUND then
      dbms_output.put_line('ppp');
     fetch cursor into file;
    loop;
    close cursor;
    end;
    但运行没有通过请问应该怎么改??
      

  6.   

    http://expert.csdn.net/Expert/topic/2419/2419130.xml?temp=.4253961
      

  7.   

    提示是“fetch”错了!
    我想写一个游标,通过游标把两条记录保存到一个变量里。以前用sql sever就写过,不过用orcale才学了几天,搞不出来!
      

  8.   

    declare 
    vchcontent varchar2(500);
    file tu_smsvc_sub_mes%ROWTYPE;
    begin
    declare 
     cursor cursor_name is select * from tu_smsvc_sub_mes;
     open cursor_name;
     fetch cursor into file;
     while cursor_name%FOUND then
      dbms_output.put_line('ppp');
     fetch cursor into file;
    loop;
    close cursor;
    end;
      

  9.   

    declare 
    vchcontent varchar2(500);
    cursor cursor_name is select * from tu_smsvc_sub_mes;
    begin
     open cursor_name;
     fetch cursor_name into file;
     while cursor_name%FOUND then
      dbms_output.put_line('ppp');
     fetch cursor into file;
     end loop;
    close cursor;
    end;
    /
      

  10.   

    我现在写成这样:
    set serveroutput on;
          declare
          v_salary varchar2(1500):='';   
          content  varchar2(1500):='';
          inti  number:=0;                    
          cursor mycursor is select content from tu_smsvc_sub_mes where code='8300'; 
          begin
           open mycursor; 
           loop
            fetch mycursor into v_salary;  
            exit when mycursor%notfound;
                begin
                inti:=1+inti;    
                content:=v_salary||content;
                end;
            end loop;    
            dbms_output.put_line(content);    
           close mycursor;      
          end;
    我还想问一下处了exit when mycursor%notfound还有什么办法控制游标的指针?要是我取游标的第2条记录呢??
      

  11.   

    mycursor%rowcount 返回当前纪录序号