Hi.
Im using a cursor to go over some data but I need to declare diferents sql statments according to a parameter. The problem seems to be that Im no able to use if statmets into this declaratios:
DECLARE
CURSOR c IS SELECT * FROM TRAFICO
IF TipoConsulta = 'mes' then
BEGIN
WHERE TO_CHAR(FECHA_BUSQUEDA, 'MM-YYYY') =To_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM-YYYY')
ELSE
WHERE FECHA_BUSQUEDA >= SYSDATE -7
END IF;
ORDER BY ID_TRAFICO;
begin
FOR r IN C LOOP
BEGIN
Utl_File.Put_Line(Arch, r.ID_TRAFICO );
i:=i+1;
END;
END LOOP;
END;
I just need to change the sql statment using an if.
How do I do this??
TNKS