Ver Mensaje Individual
  #5 (permalink)  
Antiguo 28/06/2011, 05:53
jc3000
 
Fecha de Ingreso: junio-2007
Mensajes: 891
Antigüedad: 16 años, 10 meses
Puntos: 43
Respuesta: Cursor tarda mucho en ejecutarse

Si te manejas con tablas PL, prueba esto, es muy rápido.

--
-- CARGAMOS LOS DATOS EN MEMORIA
--

select *
bulk collect
into MI_TABLA_PL
from MI_TABLA_NORMAL;

--
-- INSERTAMOS EN TABLA_DESTINO
--

FORALL i IN 1..MI_TABLA_PL.COUNT SAVE EXCEPTIONS


INSERT INTO TABLA_DESTINO MI_TABLA_PL(i);

El SAVE EXCEPTIONS indica que si hay algun error siga insertando y se guarde los registros "malos" por si los quieres tratar :

EJEMPLO ( Parece complicado, pero es muy sencillito )

errores := SQL%BULK_EXCEPTIONS.COUNT;
FOR i IN 1 .. errores
LOOP
ORAERR := SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE) ;
iteracion := SQL%BULK_EXCEPTIONS(i).ERROR_INDEX ;
insert into TABLA_ERRORES values MI_TABLA_PL(iteracion);
END LOOP;