Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/07/2011, 07:28
calichet
 
Fecha de Ingreso: marzo-2009
Mensajes: 23
Antigüedad: 15 años, 1 mes
Puntos: 0
Respuesta: busqueda sentencia de faltantes

Hola, Gracias por la atencion, revisando el codigo, para ver como agarro ese toro, voy en esto pero me sigue generando error, agradezco la colaboracion.

SELECT min(Tiempo) AS Minimo, max(Tiempo) AS Maximo FROM Tabla WHERE Documento = 'xxxxxxx';
FOR ANO IN TO_NUMBER(substr(:Minimo,1,4))..TO_NUMBER(substr(: Maximo,1,4)) LOOP
FOR MES IN 1..12 LOOP
EXECUTE IMMEDIATE ('SELECT COUNT(*) AS REGISTROS FROM Tabla WHERE Documento = to_number(xxxxxxx) AND substr(tiempo,1,4) = to_number(1998) AND substr(tiempo,5,2) = to_number(12)') BULK COLLECT INTO REGISTROS;
IF REGISTROS.COUNT = 0 THEN
dbms_output.put_line('NO EXISTE DATO DEL PERIODO ' :ANO :MES)
END IF;
END LOOP;
END LOOP;

Ahora bien, la verdad no soy ducho en cursores..... sera mejor crear un cursor ???
donde encuentro literatura de cursores para dummys.

Gracias