如何存储过程中如何遍历一个表
SQL Server:
declare @name varchar(30);   
declare my_cursor SCROLL cursor for select ProductName from kuailegu.tb_Product;   
open my_cursor;   
fetch my_cursor into @name;   
WHILE (@@fetch_status = 0)  
begin   
FETCH NEXT FROM my_cursor INTO @name;   
print @name;   
end   
CLOSE my_cursor   
DEALLOCATE my_cursor
Oracle版本:   
  declare   
      cursor   getrecord   is   select   name   from   table;   
      myname   vachar2(30);   
  begin   
      open   getrecord;   
      loop     
            fetch   getrecord   into   myname;   
            exIT   when   getrecord%notfound;   
            ....   
      end   loop;   
      close   getrecord;   
  end; 
 
                    
                     
                    
                 
                    
                 
                
            
         
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号