Error PLS-00324 when creating Package Body

1

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;
    
asked by anonymous 07.03.2014 / 23:27

1 answer

2

Your problem is that you are applying the %NOTFOUND attribute to a V_CD_ESTADO identifier without it being declared as a cursor .

You need to declare:

CURSOR V_CD_ESTADO

Documentation:

  

PLS-00324: cursor attribute may not be applied to non-cursor 'string'      

Cause: This error occurs when a cursor-attribute ("% FOUND", "% NOTFOUND", "% ROWS", "% IS_OPEN"   identifier that is not declared as a cursor or cursor variable. It   if, for example, if the variable name my_cur in my_cur% FOUND was   not properly declared as a cursor or if the variable declaration was   placed incorrectly in the block structure.

     

Action: Check the spelling and declaration of the identifier. Also confirm that the statement is correctly placed in the block   structure.

What translated:

  

PLS-00324: The cursor attribute can not be applied to a non-cursor string

     

Cause: This error occurs when an attribute cursor ("% FOUND", "% NOTFOUND", "% ROWS", "% IS_OPEN", etc.) appears next to an identifier which is not declared as a cursor or cursor variable. It occurs, for example, if the name of the variable my_cur in my_cur% FOUND was not properly declared as a cursor or if the variable declaration was placed incorrectly in the block structure.

     

Action: Check the spelling and declaration of the identifier. They also confirm that the statement is placed correctly in the block structure.

    
08.03.2014 / 00:39