1
When compiling the Package Body below, I was returned the following error:
Error(16,8): PLS-00324: cursor attribute cannot be applied to non-cursor 'V_CD_ESTADO'
What you implied is that the attribute returned by the cursor cannot be assigned to the variable. But the variable is of the same type as the return of the SELECT
... Weird, no?
I’ve done exactly the same (assign the value of a cursor to a non-cursor variable) in another function and it 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;