How to resolve fetch out of sequence in oracle?

Jan 30 2021 7:09 PM
Hi, 
 
I have a error :

ORA-01002: fetch out of sequence
 
in this PRC:
 
PROCEDURE PRC_AAA (P_FECHAINI IN BBB_RENDICION.TPPC_FCH_AP%TYPE
,P_FECHAFIN IN BBB_RENDICION.TPPC_FCH_AP%TYPE
,P_LISTA_RESP OUT sqlcur
,P_ERRORCOD OUT NUMBER
,P_ERRORMSG OUT VARCHAR2) IS
V_FECHAINI vfecha;
V_FECHAFIN vfecha;
BEGIN
V_FECHAINI := TO_CHAR(P_FECHAINI,'DD-MM-YYYY');
V_FECHAFIN := TO_CHAR(P_FECHAFIN,'DD-MM-YYYY');
OPEN P_CURSOR_1 FOR
SELECT T1.COD_RESP_AP AS COD_RESP_AP
,T1.ESTADO AS GLOSA_AP
,T1.CANAL AS CANAL
,DECODE(T1.CANAL, 10, 'Menú',
'Financiero') AS DESC_CANAL
,COUNT(T1.PROCESADOS) AS PROCESADOS
,SUM(T1.MONTO_TOTAL) AS MONTO_TOTAL
,T1.COD_SISTEMA AS COD_SISTEMA
FROM
(
SELECT
REND.TPPC_COD_AP AS COD_RESP_AP
,(SELECT GLSOL.TPPS_GLS_RESP_SOL from GLSOL where REND.TPPC_COD_AP = GLSOL.TPPS_COD_RESP_AP )AS ESTADO
,REND.TPPC_COD_CANAL AS CANAL
,REND.TPPC_ID_AP AS PROCESADOS
,REND.TPPC_MONTO_AP AS MONTO_TOTAL
,REND.TPPC_COD_SISTEMA AS COD_SISTEMA
FROM TPP_RENDICION REND
WHERE REND.TPPR_ID > 0 + UID*0
-- AND TO_DATE(TO_CHAR(REND.TPPC_FCH_AP,'DD-MM-YYYY'),'DD-MM-YYYY') BETWEEN V_FECHAINI AND V_FECHAFIN
AND TO_DATE(TO_CHAR(REND.TPPC_FCH_AP,'DD-MM-YYYY'),'DD-MM-YYYY') BETWEEN TO_DATE('08-01-2021','DD-MM-YYYY') AND TO_DATE('21-01-2021','DD-MM-YYYY')
)T1
GROUP BY T1.COD_RESP_AP, T1.ESTADO, T1.CANAL, T1.COD_SISTEMA, DECODE(T1.CANAL, 10, 'Menú Andes', 'Pilar Financiero')
ORDER BY T1.COD_RESP_AP DESC;
EXCEPTION
WHEN NO_DATA_FOUND THEN
P_ERRORCOD := SQLCODE;
P_ERRORMSG := SUBSTR(SQLERRM,1,200);
WHEN OTHERS THEN
P_ERRORCOD := SQLCODE;
P_ERRORMSG := SUBSTR(SQLERRM,1,200);
END PRC_AAA;
 
What is grong here?
 
Thanks

Answers (2)