When compiling the Package Body below, I was returned the following error:
Error (16,8): PLS-00324: cursor attribute can not be applied to non-cursor 'V_CD_ESTADO'
What implied is that the attribute returned by the cursor can not be assigned to the variable. But the variable is of the same type as the return of SELECT
... Strange, is not it?
I have already done exactly the same (assigning the value of a cursor to a non-cursor variable) in another function and worked.
CREATE OR REPLACE PACKAGE BODY PCK_TB_ESTADO
IS
FUNCTION FNC_VALIDA_ESTADO
(P_CD_ESTADO IN TB_FUNCIONARIO.CD_ESTADO%TYPE)
RETURN BOOLEAN
IS
CURSOR C_VERIFICA
IS
SELECT CD_ESTADO
FROM TB_FUNCIONARIO
WHERE CD_ESTADO = P_CD_ESTADO;
V_CD_ESTADO TB_FUNCIONARIO.CD_ESTADO%TYPE;
BEGIN
OPEN C_VERIFICA;
FETCH C_VERIFICA INTO V_CD_ESTADO;
IF V_CD_ESTADO%NOTFOUND THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
CLOSE C_VERIFICA;
END;
END;