How to Fix PLS-00201: Identifier Must Be Declared in Oracle

Resolve PLS-00201 by correcting the name, creating the missing object, or granting access to another schema's object directly.

PLS-00201 is a compile error: the PL/SQL compiler found a name it cannot resolve to any variable, procedure, function, package, or table it can see. In an anonymous block it arrives under ORA-06550, which gives the line and column. Typical causes are a misspelled name, an object that does not exist in the schema, or an object in another schema without an EXECUTE or SELECT grant to the current user.

Reproduce the Error

Example:

begin
  demo_send_alert('NA101');          -- no such procedure
end;
/
begin
  dbms_outpt.put_line('Boarding');   -- misspelled package name
end;
/

Output:

  demo_send_alert('NA101');          -- no such procedure
  *
ERROR at line 2:
ORA-06550: line 2, column 3:
PLS-00201: identifier 'DEMO_SEND_ALERT' must be declared
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored

  dbms_outpt.put_line('Boarding');   -- misspelled package name
  *
ERROR at line 2:
ORA-06550: line 2, column 3:
PLS-00201: identifier 'DBMS_OUTPT.PUT_LINE' must be declared
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored

ORA-06550 points to line 2, column 3, and PLS-00201 names the identifier: a procedure that does not exist, and a misspelled DBMS_OUTPUT.

Fix: Create or Correct the Name

Example:

create or replace procedure demo_send_alert (p_flight varchar2) is
begin
  dbms_output.put_line('Alert for ' || p_flight);
end;
/
set serveroutput on
begin
  demo_send_alert('NA101');
  dbms_output.put_line('Boarding');
end;
/
select object_name, object_type from user_objects where object_name = 'DEMO_SEND_ALERT';

Output:

Procedure DEMO_SEND_ALERT compiled

Alert for NA101
Boarding

PL/SQL procedure successfully completed.

OBJECT_NAME        OBJECT_TYPE
__________________ ______________
DEMO_SEND_ALERT    PROCEDURE

When the Object Is in Another Schema

  • Check that it exists and who owns it in ALL_OBJECTS; if it is missing there, the current user has no privilege on it.
  • The owner grants access, for example GRANT EXECUTE ON owner.procedure_name TO user_name.
  • Inside stored procedures, privileges received through a role do not count; the grant must go to the user directly.
  • Prefix the owner, owner.procedure_name, or create a synonym.

Things to Know

  • A variable used outside the block where it is declared also raises PLS-00201.
  • Quoted identifiers are case-sensitive: "MyProc" and MYPROC are different names.

Related Guides

Conclusion

PLS-00201 means the compiler cannot see the name. Fix the spelling, create the missing object, or have the owner grant access directly to the user, and prefix the owner or use a synonym.

Vinish Kapoor
Vinish Kapoor

An Oracle ACE, author of four books on Oracle APEX, SQL and PL/SQL, and Oracle Forms, and a software developer building Oracle database applications since 2001.

guest

0 Comments
Oldest
Newest Most Voted