declare 
type c1 is ref cursor; 
emp_cursor c1; 
v_ename emp.ename%type; 
v_sal emp.sal%type; 
  begin 
      open emp_cursor for 
            select ename,sal from emp where deptno=10; 
      loop 
            fecth emp_cursor into v_ename,v_sal; 
            exit when emp_cursor%notfound; 
            dbms_output.put_line(v_ename); 
        end loop; 
        close emp_cursor; 
        
  end; 
/  

解决方案 »

  1.   

    是什么错?
    dbms_output.put_line(v_ename); 产生的output长度问题吗?
      

  2.   

    type cursor_type is ref cursor;
    cursor u_cursor_item is select 1 from dual;
    begin
    open u_cursor_item;
         loop
         fetch u_cursor_item into v_aaa;
         exit when u_cursor_item%notfound;
         /*主题*/   
         end loop ;
         close u_cursor_item;
      

  3.   

    报这个错,谁有能运行的例子(Scott tiger)第 10 行出现错误:
    ORA-06550: 第 10 行, 第 19 列:
    PLS-00103: 出现符号 "EMP_CURSOR"在需要下列之一时:
    := . ( @ % ;
    ORA-06550: 第 10 行, 第 48 列:
    PLS-00103: 出现符号 ";"在需要下列之一时:
    . ( , % from
    ORA-06550: 第 14 行, 第 9 列:
    PLS-00103: 出现符号 "CLOSE"在需要下列之一时:
    end not pragma final
    instantiable order overriding static member constructor ma
    ORA-06550: 第 16 行, 第 6 列:
    PLS-00103: 出现符号 "end-of-file"在需要下列之一时:
    begin function
    package pragma procedure subtype type use <an identifier>
    <a double-quoted delimited-identifier> form current cursor
      

  4.   

    等 级: 
    结帖率:0.00%   begin 
          open emp_cursor for 
                select ename,sal from emp where deptno=10; 
          loop 
                fecth emp_cursor into v_ename,v_sal; 
                exit when emp_cursor%notfound; 
                dbms_output.put_line(v_ename); 
            end loop; 
            close emp_cursor; 
            
      end; 
    /
    仔细看看所有的红色部分。fecth应为fetch另外,期待打破0记录,呵呵。。
      

  5.   


    使用工具,如PL/SQL。并开启其提示功能,事半功倍!
      

  6.   

    行号、列号都有,就检测相应的地方啊。sqlplus的show err用起来还是蛮爽的,一直用它调存储过程。