PLS-00324 error when creating Body Package

Asked

Viewed 153 times

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;

1 answer

2

Your problem is you’re applying the attribute %NOTFOUND to an identifier V_CD_ESTADO without it having been 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", etc.) appears following an Identifier that is not declared as a cursor or cursor variable. It occurs, 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 incorrectly placed in the block Structure.

Action: Check the Spelling and declaration of the Identifier. Also confirm that the declaration is placed correctly in the block Structure.

That translated:

PLS-00324: The cursor attribute cannot be applied to a non-cursor string'

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.