set serveroutput on ;declare  cursor yan_cur is select * from yanyan ;
 
 type yan_table is table of yanyan%rowtype;
 
 yan_tab yan_table;
 
begin  open yan_cur;
 
 loop 
 
  fetch yan_cur bulk collect into yan_tab limit 2;
  
  for i in 1...yan_tab.count loop
  
   dbms_output.put_line('学号:'||yan_tab(i).xh||'姓名:'
   
                        ||yan_tab(i).xm||'工资:'||yan_tab(i).sal);
                        
  end loop;
 
 exit when yan_cur%notfound;
 
 end loop;
 
 close yan_cur;
 
end;/
显示Error at line 3
ORA-06550: line 17, column 13:
PLS-00103: Encountered the symbol "." when expecting one of the following:   * & - + / at mod remainder rem .. <an exponent (**)> ||
   multiset要怎么改求教

解决方案 »

  1.   

    2个错误
    1) for i in 1..yan_tab.count
    这里是2个点
    2)你已经用了bulk collect into,一次性把所有记录提取到yan_tab中,就不需要外层的loop了declare  
     cursor yan_cur is select * from yanyan ; 
     type yan_table is table of yanyan%rowtype;
     yan_tab yan_table;
    begin  
     open yan_cur;
     fetch yan_cur bulk collect into yan_tab limit 2;
      for i in 1..yan_tab.count loop
      dbms_output.put_line('学号:'||yan_tab(i).xh||'姓名:'
      ||yan_tab(i).xm||'工资:'||yan_tab(i).sal);
      end loop; 
     close yan_cur;
    end;
      

  2.   

    可以了谢谢。。那个yan_tab.count是什么意思?
      

  3.   

    yan_tab.count就是yan_tab这里面放的记录数
      

  4.   

    抱歉,没看到你用了limit子句,那么只有那个..的错误了。declare  
     cursor yan_cur is select * from yanyan ; 
     type yan_table is table of yanyan%rowtype;
     yan_tab yan_table;
    begin  
     open yan_cur;
     loop
    fetch yan_cur bulk collect into yan_tab limit 2;
    for i in 1..yan_tab.count loop
    dbms_output.put_line('学号:'||yan_tab(i).xh||'姓名:'
    ||yan_tab(i).xm||'工资:'||yan_tab(i).sal);
    end loop; 
    exit when yan_cur%notfound;
      end loop;
     close yan_cur;
    end;