只听说过使用游标会发生切换 所以采用批量BULK 方法
下面4种情况使用游标的方法 哪种会发生切换 还是全部分会发生切换?
1
  Declare
     Cursor myCur is select ename,job,sal,empno from emp;
     varE myCur%rowType;
  Begin
     open myCur;
     loop
        fetch myCur into varE;
        exit when myCur%notfound;
        dbms_output.put_line(myCur%rowCount||'    '||vare.empno||'    '||vare.ename||'    '||vare.sal);
     end loop;
  End
2 Declare
     Cursor myCur is select * from emp;
   varE myCur%rowType;
  Begin
     for varA in myCur
      loop
         select ename,job,sal,empno  into varE from emp where empno= vara.empno;
         dbms_output.put_line(vare.empno||'    '||vare.ename||'    '||vare.sal);
      end loop;
  End;
3
 
  Declare
     Cursor myCur is select ename,job,sal from emp;
     type type_ename  is table of emp.ename %type index by binary_integer;
     type type_job  is table of emp.job %type index by binary_integer;
     type type_sal  is table of emp.emp %type index by binary_integer;
     l_ary_name  type_ename;
     l_ary_job    type_job;
     l_ary_sal    type_sal;
  Begin
     open myCur;
     loop
        fetch myCur bulk collect into 
        l_ary_name,  
        l_ary_job,   
        l_ary_sal
        limite 1;
        exit when myCur%notfound;
        dbms_output.put_line(myCur%rowCount||' '||l_ary_name(1)||' '||l_ary_job(1)||' '||l_ary_sal(1));
     end loop;
  End4  Declare
     Cursor myCur is select ename,job,sal from emp;
     type type_ename  is table of emp.ename %type index by binary_integer;
     type type_job  is table of emp.job %type index by binary_integer;
     type type_sal  is table of emp.emp %type index by binary_integer;
     l_ary_name  type_ename;
     l_ary_job    type_job;
     l_ary_sal    type_sal;
  Begin
     open myCur;
     loop
        fetch myCur bulk collect into 
        l_ary_name,  
        l_ary_job,   
        l_ary_sal
        limite 1;
        forall i in 1..l_ary_name.count
          insert into  table_b
          (b.name,b.job,b.sal)
         values(l_ary_name(i),l_ary_job(i),l_ary_sal(i))
        exit when myCur%notfound;     end loop;
  End