Error pls 00201 identifier must be declared

The PLS-00201: identifier must be declared error happens when the identifier is used without being declared in the PL/SQL code. Oracle Variables and other identifiers must either be declared or made available before they’ve been used. The variable is used in the code, but it isn’t declared in the database or hasn’t been given permission to use it. It throws an error PLS-00201: identifier must be declared while calling the database identifier.

The PLS-00201: identifier must be declared error happens when the identifier is used without being declared in the PL/SQL code. Oracle Variables and other identifiers must either be declared or made available before they’ve been used. The variable is used in the code, but it isn’t declared in the database or hasn’t been given permission to use it. It throws an error PLS-00201: identifier must be declared while calling the database identifier.

In the declaration block, the oracle variables should be declared. In PL/SQL code, the variable can be used. The variable cannot be used by PL/SQL code if it is not declared. The variable is not available. The value can neither assign to the variable nor read from the variable. The identifier is not declared and is used in the PL/SQL code, so Oracle will throw an error PLS-00201: identifier must be declared.

Exception

The stack trace for the PLS-00201: identifier must be declared error will look like this. The oracle error would show the name of the identifier that it could not locate in the database, was inaccessible, or did not have authorization to execute.

Error report -
ORA-06550: line 3, column 26:
PLS-00201: identifier 'EMPNAME' must be declared
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:n%s"

Cause

The identifier cannot be used if it has not been declared in the Oracle database. The memory needed to store and retrieve the value will be created by the identifier declaration. Value cannot assign or retrieve from the variable if the identifier is not declared. The error would be thrown if you use a variable that is not declared or defined in the Oracle database.

Problem

If an identifier is used without being declared in the PL/SQL code, the identifier would not be available in the database. Until the identifier is declared, it can not be used in the PL/SQL code. Otherwise, the identifier would throw an error, prompting you to declare it.

declare
begin
    dbms_output.put_line(empname);
end;

Output

declare
begin
    dbms_output.put_line(empname);
end;
Error report -
ORA-06550: line 3, column 26:
PLS-00201: identifier 'EMPNAME' must be declared
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

Solution 1

The identifier in the code may be misspelled. If the variable is declared, the identifier is misspelled. The spelling of the identifier should be corrected. If the identifier is not found in the declaration, it must be declared. If it hasn’t already been declared, the identifier must be declared.

declare
    empname varchar2(10) :='yawin';
begin
    dbms_output.put_line(empname);
end;

Output

Yawin
PL/SQL procedure successfully completed.

Solution 2

It’s likely that the thing you’re searching for isn’t available, or that it’s misspelled. The error will be thrown when you call the members of the referenced identifier. The error would be thrown if the system packages are misspelled or not visible. The system package’s spelling needs to be changed.

declare
    empname varchar2(10) :='yawin';
begin
    dbms_ooutput.put_line(empname);
end;

Exception

declare
    empname varchar2(10) :='yawin';
begin
    dbms_ooutput.put_line(empname);
end;
Error report -
ORA-06550: line 4, column 5:
PLS-00201: identifier 'DBMS_OOUTPUT.PUT_LINE' must be declared
ORA-06550: line 4, column 5:
PL/SQL: Statement ignored

Solution

declare
    empname varchar2(10) :='yawin';
begin
    dbms_output.put_line(empname);
end;

Output

Yawin
PL/SQL procedure successfully completed.

Solution 3

It’s likely that the referring identifier object isn’t accessible. When the identifier is run, it is unable to locate the identifier’s definition. It is possible that the identifier will not be created or that it will be deleted. It’s likely that the identifier name is misspelled. Check that the identifier has been created and is usable. The name of the identifier reference should be right.

exec printmyname;

Exception

BEGIN printmyname; END;
Error report -
ORA-06550: line 1, column 7:
PLS-00201: identifier 'PRINTMYNAME' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Solution

create procedure printmyname as
begin
dbms_output.put_line('yawin');
end;
set serveroutput on
exec printmyname;

Output

Yawin
PL/SQL procedure successfully completed.

Solution 4

It’s possible that the identifier object in the Oracle database doesn’t have permission to run. Permission needs to be granted. To receive this authorization, you may need to contact your database administrator.

create procedure myproject.printmyname as
begin
dbms_output.put_line('yawin');
end;
set serveroutput on
exec printmyname;

Exception

BEGIN printmyname; END;
Error report -
ORA-06550: line 1, column 7:
PLS-00201: identifier 'PRINTMYNAME' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Solution

grant execute on myproject.printmyname to yawin; 
set serveroutput on
exec myproject.printmyname;

Output

Yawin
PL/SQL procedure successfully completed.

Содержание

  1. An example to show one cause of a «PLS-00201: identifier must be declared» error (Doc ID 391047.1)
  2. Applies to:
  3. Purpose
  4. Scope
  5. Details
  6. To view full details, sign in with your My Oracle Support account.
  7. Don’t have a My Oracle Support account? Click to get started!
  8. PLS-00201: identifier must be declared
  9. Exception
  10. Cause
  11. Problem
  12. Output
  13. Solution 1
  14. Output
  15. Solution 2
  16. Exception
  17. Solution
  18. Output
  19. Solution 3
  20. Exception
  21. Solution
  22. Output
  23. Solution 4
  24. Error: PLS-00201: identifier ‘DBMS_CRYPTO’ must be declared.
  25. PLS-00201 error calling function in package
  26. Comments
  27. strange error..PLS-00201: identifier ‘PLITBLM’ must be declared
  28. Comments

An example to show one cause of a «PLS-00201: identifier must be declared» error (Doc ID 391047.1)

Last updated on MARCH 04, 2022

Applies to:

Purpose

The «PLS-00201: identifier ‘XYZ’ must be declared» error is a fairly common yet misunderstood error due to how Oracle handles privileges granted directly and privileges granted via a Role in conjunction to Stored Procedures.

This Note should help illustrate the difference.

Scope

The example provided within creates two users where User1 owns the table and stored procedure and USER2 attempts to execute the procedure within User1’s schema.

The stored procedure execute a SELECT from two tables.

User2 attempts to access User1’s procedure which in turn Selects from User1’s table.

Referencing of the procedure fails when the privileges are granted via a Role, but works when granted directly.

Details

To view full details, sign in with your My Oracle Support account.

Don’t have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.

Oracle offers a comprehensive and fully integrated stack of cloud applications and platform services. For more information about Oracle (NYSE:ORCL), visit oracle.com. пїЅ Oracle | Contact and Chat | Support | Communities | Connect with us | | | | Legal Notices | Terms of Use

Источник

PLS-00201: identifier must be declared

The PLS-00201: identifier must be declared error happens when the identifier is used without being declared in the PL/SQL code. Oracle Variables and other identifiers must either be declared or made available before they’ve been used. The variable is used in the code, but it isn’t declared in the database or hasn’t been given permission to use it. It throws an error PLS-00201: identifier must be declared while calling the database identifier.

In the declaration block, the oracle variables should be declared. In PL/SQL code, the variable can be used. The variable cannot be used by PL/SQL code if it is not declared. The variable is not available. The value can neither assign to the variable nor read from the variable. The identifier is not declared and is used in the PL/SQL code, so Oracle will throw an error PLS-00201: identifier must be declared.

Exception

The stack trace for the PLS-00201: identifier must be declared error will look like this. The oracle error would show the name of the identifier that it could not locate in the database, was inaccessible, or did not have authorization to execute.

Cause

The identifier cannot be used if it has not been declared in the Oracle database. The memory needed to store and retrieve the value will be created by the identifier declaration. Value cannot assign or retrieve from the variable if the identifier is not declared. The error would be thrown if you use a variable that is not declared or defined in the Oracle database.

Problem

If an identifier is used without being declared in the PL/SQL code, the identifier would not be available in the database. Until the identifier is declared, it can not be used in the PL/SQL code. Otherwise, the identifier would throw an error, prompting you to declare it.

Output

Solution 1

The identifier in the code may be misspelled. If the variable is declared, the identifier is misspelled. The spelling of the identifier should be corrected. If the identifier is not found in the declaration, it must be declared. If it hasn’t already been declared, the identifier must be declared.

Output

Solution 2

It’s likely that the thing you’re searching for isn’t available, or that it’s misspelled. The error will be thrown when you call the members of the referenced identifier. The error would be thrown if the system packages are misspelled or not visible. The system package’s spelling needs to be changed.

Exception

Solution

Output

Solution 3

It’s likely that the referring identifier object isn’t accessible. When the identifier is run, it is unable to locate the identifier’s definition. It is possible that the identifier will not be created or that it will be deleted. It’s likely that the identifier name is misspelled. Check that the identifier has been created and is usable. The name of the identifier reference should be right.

Exception

Solution

Output

Solution 4

It’s possible that the identifier object in the Oracle database doesn’t have permission to run. Permission needs to be granted. To receive this authorization, you may need to contact your database administrator.

Источник

Error: PLS-00201: identifier ‘DBMS_CRYPTO’ must be declared.

I have a strange problem. My oracle version is 10.2.0.4.0 on linux server. I have to use ‘DBMS_CRYPTO’ oracle supplied package for one requirement. Here, first I wrote one anonymous PLSQL block,

DECLARE
INPUT_STRING VARCHAR2(200);
OUTPUT_STRING VARCHAR2(200);
ENCRYPTED_RAW RAW(2000);
DECRYPTED_RAW RAW(2000);
NUM_KEY_BYTES NUMBER := 256 / 8;
KEY_BYTES_RAW RAW(32);
ENCRYPTION_TYPE PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_AES256 DBMS_CRYPTO.CHAIN_CBC DBMS_CRYPTO.PAD_PKCS5;
BEGIN

DBMS_OUTPUT.PUT_LINE(‘Original String Input: ‘ || INPUT_STRING);

ENCRYPTED_RAW := DBMS_CRYPTO.ENCRYPT(SRC => UTL_I18N.STRING_TO_RAW(INPUT_STRING,’AL32UTF8′),
TYP => ENCRYPTION_TYPE,
KEY => KEY_BYTES_RAW);

DBMS_OUTPUT.PUT_LINE(‘Encrypted String: ‘ || ENCRYPTED_RAW);

DECRYPTED_RAW := DBMS_CRYPTO.DECRYPT(SRC => ENCRYPTED_RAW,
TYP => ENCRYPTION_TYPE,
KEY => KEY_BYTES_RAW);

OUTPUT_STRING := UTL_I18N.RAW_TO_CHAR(DECRYPTED_RAW, ‘AL32UTF8’);

DBMS_OUTPUT.PUT_LINE(‘Decrypted String Output: ‘ || OUTPUT_STRING);

IF INPUT_STRING=OUTPUT_STRING THEN
DBMS_OUTPUT.PUT_LINE(‘Encryption and decryption has happened in a expected manner.’);
ELSE
DBMS_OUTPUT.PUT_LINE(‘Encryption and decryption has not happened properly.’);
END IF;
END;

It is compiling without any error.
Same I wrote it in Procedure, but im getting the following error.

CREATE OR REPLACE PROCEDURE encrypt_hema
/********************************************************************************************
* Procedure Name : ENCRYPT_HEMA
* Parameters : p_input_text,p_encrypted_value,p_decrypted_value,p_err_msg
* Purpose : To encrypt a given text
* Author : Hemakumar for Q3 Enh 2012.
* Created : 22-OCT-12
********************************************************************************************/
(
p_input_text IN VARCHAR2,
p_encrypted_value OUT RAW,
p_decrypted_value OUT RAW,
p_err_msg OUT VARCHAR2)
IS

chk_exception EXCEPTION;
v_encrypted_text VARCHAR2(4000);
v_decrypted_text VARCHAR2(4000);
ENCRYPTED_RAW RAW(2000);
DECRYPTED_RAW RAW(2000);
NUM_KEY_BYTES NUMBER := 256 / 8;
KEY_BYTES_RAW RAW(32);
ENCRYPTION_TYPE PLS_INTEGER := sys.dbms_crypto.ENCRYPT_AES256 DBMS_CRYPTO.CHAIN_CBC DBMS_CRYPTO.PAD_PKCS5;

IF p_input_text IS NULL THEN
p_err_msg := exc_handler.display_warning(8414);
RAISE chk_exception;
END IF;

IF p_input_text IS NOT NULL THEN

ENCRYPTED_RAW := DBMS_CRYPTO.ENCRYPT(SRC => UTL_I18N.STRING_TO_RAW(p_input_text,’AL32UTF8′),
TYP => ENCRYPTION_TYPE,
KEY => KEY_BYTES_RAW);

v_encrypted_text := ENCRYPTED_RAW;
p_encrypted_value:=v_encrypted_text;

Источник

PLS-00201 error calling function in package

I have a package defined that’s exhibiting odd behavior. Called PKGAPPLICATIONS, it contains a number of stored procedures, one of which, fGetReportTitle, returns with the above error when I call it through my application code.

The Specification and Body code compiles cleanly, I can successfully execute the function in TOAD’s Procedure Editor, and I can see the function when I view the package in TOAD’s Schema Browser. I can also successfully call other Stored Procs in the same package.

I’ve checked the spelling, the parameter data types, lengths, execution rights, etc, but still get the PLS-00201 error when I execute the application. Anybody have any ideas??

Thanks in advance.

Thanks for your reply.

Yes, the function is included in the package spec.
No, the method is not overloaded.
There’s a proc in the same package with a similar name. The two names are fGetReportName and ssp_GetReportName. Could they be conflicting?
My DBA tells me that we’re not executing via a role because the application signs on as the database owner and therefore has execution rights. The fact that the other SPs in the package are available to the application supports that assertion, I think.

PLS-00201: identifier ‘string’ must be declared
Cause: You tried to reference either an undeclared variable, exception, procedure, or other item, or an item to which no privilege was granted or an item to which privilege was granted only through a role.
Action: 1) Check your spelling and declaration of the referenced name. 2) Verify that the declaration for the referenced item is placed correctly in the block structure. 3) If the referenced item is indeed declared but you don’t have privileges to refer to that item, for security reasons, you will be notified only that the item is not declared. 4) If the referenced item is indeed declared and you believe that you have privileges to refer to that item, check the privileges; if the privileges were granted only via a role, then this is expected and documented behavior. Stored objects (packages, procedures, functions, triggers, views) run in the security domain of the object owner with no roles enabled except PUBLIC. Again, you will be notified only that the item was not declared.

Did you really check all called/procedures in all the possible calling stacks? Including the standard packages that you may call ?
You can also use USER_DEPENDENCIES to find used objects.

Because Oracle unfortunately does not give the object name that triggers the error, you might be forced to debug your code until you find the object that triggers this error.

Who is the owner of the package and who is calling? if the owner is different from who is calling then create a public synonym fo the package and the grant execute on the package to the caller.

You’re asking about a month too late. I would assume that the OP has already figured it out by now.

Hi,
I recently installed ERWin connect through ERWin4.1 and when I am trying to connect using userid/password and connection string for my database it is giving error :
oracle vers. 8.xxorcle9i10g error 6550 sevierty 16
‘PLS-00201 : identifier ‘MM_USER_HASHPROFILE2’ must be declared.

Could someone please guild me through that error.

I went through your post regarding the PLS-00201 error.

I faced the same problem while selecting the data from a table using a cursor which
was written within a PL/SQL custom function. Oracle could not resolve the table name
referenced in the select statement and hence it was throwing the PLS-00201 error.

I tried selecting the data from the referenced table using a select statement. The table existed in the database and i had select priviliges granted on the table through a role which was actually the cause of the error.

All i mean to say is select priviliges should not be granted through a role but should be directly granted to the user for the select statements on tables written within procedures/functions to work. This will avoid the PLS-00201 error.

SQL> grant programmer to user123;

Say programmer is a role containing select priviliges on a table A belonging to a schema. When a select statement is written within a procedure/function being executed by user123, it will lead to the error PLS-00201.

This can be avoided by:

SQL> grant select on schema.A to user123;

SQL> grant select any table to user123;

Assigning direct priviliges to a user rather than assigning priviliges therough a role
will avoid such errors.

I verified the solution practically and the code is working fine in my case.. I confirmed
the same on Oracle Metalink.

Hope this helps you.. Please revert back to me for any further clarifications.

Источник

strange error..PLS-00201: identifier ‘PLITBLM’ must be declared

could not find any such errors.

SQL> set serveroutput on size 10000
SQL> DECLARE
2 TYPE CUSTOMER_RECORD IS RECORD (CUSTOMER_ACCT_ID NUMBER,CUSTOMER_NAME VARCHAR2(2000));
3 TYPE CUSTOMER_REC IS TABLE OF CUSTOMER_RECORD INDEX BY BINARY_INTEGER;
4 LREC_CUSTOMER_RECORD CUSTOMER_RECORD;
5 LT_CUSTOMER_REC CUSTOMER_REC;
6 BEGIN
7 LREC_CUSTOMER_RECORD.CUSTOMER_ACCT_ID:=10;
8 LREC_CUSTOMER_RECORD.CUSTOMER_NAME:=’BHAGAT’;
9 LT_CUSTOMER_REC(1):=LREC_CUSTOMER_RECORD;
10 DBMS_OUTPUT.PUT_LINE(LT_CUSTOMER_REC(1).CUSTOMER_ACCT_ID);
11 DBMS_OUTPUT.PUT_LINE(LT_CUSTOMER_REC(1).CUSTOMER_NAME);
12 end;
13 /
10
BHAGAT

PL/SQL procedure successfully completed.

Check the contents you copied before applying in sqlplus. Try to exit the current session and run the code in new session.

The PL/SQL Engine uses several system (SYS user) packages. The error is likely caused by:
— a missing package
— an invalidated package

Run the following SQL as user SYS:
SELECT object_name,status,owner from DBA_OBJECTS where status = ‘INVALID’

Try and recompile these invalid packages, e.g.
ALTER PACKAGE

In the case of a missing package, the problem could be a tad more serious. What is the db version? Is this a new install? If not, what changes were recently made?

Thanks for the reply.
It works perfectly fine in my system.
However my colleague is encountering this error in his PC,with exactly the same piece of code.I wonder if version problems or something of that sort could attribute to this error?

Источник

Troubleshooting

Problem

The «PLS-00201: identifier ‘DBMS_LOCK’ must be declared» error is seen in the SystemOut.log file with a newly created IBM Business Process Manager Version 7.5 profile or with a profile that is migrated from a previous version.

Symptom

The following exception is observed in the SystemOut.log file:

[7/26/11 13:52:09:695 CDT] 0000001c wle           E   CWLLG2229E: An exception occurred in an EJB call.  Error: ConnectionCallback; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-06550: line 1, column 13:

PLS-00201: identifier ‘DBMS_LOCK’ must be declared

ORA-06550: line 1, column 7:

PL/SQL: Statement ignored

org.springframework.jdbc.BadSqlGrammarException: ConnectionCallback; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-06550: line 1, column 13:

PLS-00201: identifier ‘DBMS_LOCK’ must be declared

ORA-06550: line 1, column 7:

PL/SQL: Statement ignored

 at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:111)

 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322)

 at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:349)

 at com.lombardisoftware.server.tracking.loader.LockHolder.runLockQuery(LockHolder.java:170)

 at com.lombardisoftware.server.tracking.loader.LockHolder.runLockQuery(LockHolder.java:166)

 at com.lombardisoftware.server.tracking.loader.LockHolder.lockSystemTable(LockHolder.java:70)

 at com.lombardisoftware.server.tracking.transfer.DataTransferCore.transferData(DataTransferCore.java:82)

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

 at java.lang.reflect.Method.invoke(Method.java:611)

 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)

 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)

 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)

 at com.lombardisoftware.utility.spring.TransactionInterceptor$1.call(TransactionInterceptor.java:52)

 at com.lombardisoftware.utility.spring.ProgrammaticTransactionSupport$1.doInTransaction(ProgrammaticTransactionSupport.java:317)

 at org.springframework.transaction.jta.WebSphereUowTransactionManager$UOWActionAdapter.run(WebSphereUowTransactionManager.java:306)

 at com.ibm.ws.uow.UOWManagerImpl.runUnderNewUOW(UOWManagerImpl.java:1067)

 at com.ibm.ws.uow.UOWManagerImpl.runUnderUOW(UOWManagerImpl.java:628)

Cause

The Oracle schema or user does not have access to the DBMS_LOCK package.

Environment

The issue is seen when you have a newly created or a migrated IBM Business Process Manager V7.5 profile with Oracle as the back-end database

Resolving The Problem

Grant Execute permission to the Oracle user or schema that is used for the performance database. Complete the following steps:

  1. Stop the application server.
  2. On the Oracle server, use the ‘SQL Plus Worksheet’ Oracle tool.
  3. Log into the database using administrative credentials.
  4. Run the following script:
    GRANT execute ON DBMS_LOCK TO <schema_name>;

    where <schema_name> is the userID that is used for the performance database.

5. Restart the server

Related Information

[{«Product»:{«code»:»SSFTDH»,»label»:»IBM Business Process Manager Standard»},»Business Unit»:{«code»:»BU053″,»label»:»Cloud & Data Platform»},»Component»:»Installation / Configuration»,»Platform»:[{«code»:»PF002″,»label»:»AIX»},{«code»:»PF016″,»label»:»Linux»},{«code»:»PF027″,»label»:»Solaris»},{«code»:»PF033″,»label»:»Windows»}],»Version»:»8.5;8.0;7.5″,»Edition»:»»,»Line of Business»:{«code»:»LOB45″,»label»:»Automation»}},{«Product»:{«code»:»SSFTN5″,»label»:»IBM Business Process Manager Advanced»},»Business Unit»:{«code»:»BU053″,»label»:»Cloud & Data Platform»},»Component»:»Installation / Configuration»,»Platform»:[{«code»:»PF002″,»label»:»AIX»},{«code»:»PF016″,»label»:»Linux»},{«code»:»PF027″,»label»:»Solaris»},{«code»:»PF033″,»label»:»Windows»}],»Version»:»8.0;7.5.1;7.5″,»Edition»:»»,»Line of Business»:{«code»:»LOB45″,»label»:»Automation»}}]

PLS-00201 means that the identifier you specified in the statement has never declared, so it cannot be used by the stored procedure.

In this post, we’ll talk about some error patterns of PLS-00201.

  1. Undeclared Variable
  2. DBMS_SQL
  3. DBMS_LOCK

A. Undeclared Variable

What is undeclared variable? Let’s see an example to make it clear.

SQL> set serveroutput on;
SQL> begin
  2    select first_name into v_fn from employees where last_name = 'Chen';
  3    dbms_output.put_line('The first name is: ' || v_fn);
  4  end;
  5  /
  select first_name into v_fn from employees where last_name = 'Chen';
                         *
ERROR at line 2:
ORA-06550: line 2, column 26:
PLS-00201: identifier 'V_FN' must be declared
ORA-06550: line 2, column 31:
PL/SQL: ORA-00904: : invalid identifier
ORA-06550: line 2, column 3:
PL/SQL: SQL Statement ignored
ORA-06550: line 3, column 49:
PLS-00201: identifier 'V_FN' must be declared
ORA-06550: line 3, column 3:
PL/SQL: Statement ignored

In the example, it found an identifier which is not declare anywhere in the programming unit.

Solution

In fact, the identifier is a local variable, we just forgot to declare it before using. Let’s declare the variable as a string.

SQL> declare
  2    v_fn varchar2(25);
  3  begin
  4    select first_name into v_fn from employees where last_name = 'Chen';
  5    dbms_output.put_line('The first name is: ' || v_fn);
  6  end;
  7  /
The first name is: John

PL/SQL procedure successfully completed.

The final result has been successful output.

B. DBMS_SQL

Some SYS’s packages are very common to PUBLIC to EXECUTE, such as DBMS_SQL, DBMS_LOB or UTL_FILE.

PLS-00201: identifier 'DBMS_SQL' must be declared

Solution

In such case, the right privileges may be gone or revoked from PUBLIC. I have provided the solution in the post: How to Resolve PLS-00201: identifier ‘DBMS_SQL’ must be declared.

C. DBMS_LOCK

DBMS_LOCK does not open to PUBLIC, it should be granted to specific user to execute whenever required.

SQL> begin
  2    dbms_lock.sleep(10);
  3  end;
  4  /
  dbms_lock.sleep(10);
  *
ERROR at line 2:
ORA-06550: line 2, column 3:
PLS-00201: identifier 'DBMS_LOCK' must be declared
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored

Solution

We should grant EXECUTE privilege on the package to the user by SYS.

SQL> show user
USER is "SYS"
SQL> grant execute on dbms_lock to hr;

Grant succeeded.

Then we run the programming unit again.

SQL> begin
  2    dbms_lock.sleep(10);
  3  end;
  4  /

PL/SQL procedure successfully completed.

September 15, 2020

Hi,

I got ” PLS-00201: Identifier must be declared ” error in Oracle.

Details of error are as follows.

PLS-00201: Identifier must be declared

This error is related with the reference either an undeclared variable, exception, procedure or etc.., which no privilege was granted or an item to which privilege was granted only through a role.

Check if you access undeclared variable or you may execute invalid package/procedure/function.

Or Check the package/procedure/function if they exists or not, probably they don’t exist or your user don’t have permission for these objects.

Give permission as follows.

grant execute on (package_Name or table_name) to user;

Or If you got PLS-00201: identifier ‘DBMS_LOCK’ must be declared error, then you can grant it as follows.

SQL> grant execute on dbms_lock to USER_NAME;

Grant succeeded.

Do you want to learn Oracle SQL, then read the following articles.

Oracle SQL Tutorials For Beginners – Learn Oracle SQL from scratch with Oracle SQL Online Course

 5,406 views last month,  1 views today

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

Портал IT-специалистов: программирование, администрирование, базы данных

  • Страница:
  • 1
  • 2

declare
st number := 1000000;
t varchar2 (100) := ‘Text to be inserted into Exam’;
t1 varchar2 (200);
….

PLS-00201: identifier ‘Text to be inserted into Exam’ must be declared

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

Привет.
Скажи пожалуйста а зачем вы пробел ставите между varchar2 i (100)?

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

Не помогло…
все написано правильно, но ошибка таже самая …

declare
st number := 1000000;
text varchar2(100) := ‘Text to be inserted into Exam’;
t varchar2(200);
begin
t := ‘Test(‘ || st || ‘,’ || ‘»‘ || text || ‘»‘ || ‘)’;
var_pack.run_proc(t);

Procedure Run_Proc ( stmt IN VARCHAR2 ) is
num BINARY_INTEGER := 0;
BEGIN
dbms_job.submit( num, stmt||’;’, SYSDATE );
COMMIT;
END;

ошибка: PLS-00201: identifier ‘Text to be inserted into Exam’ must be declared
PL/SQL statement ignored
затем ORA-06512: line 18 — Это dbms_job.submit( num, stmt||’;’, SYSDATE );

В чем же дело ?

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

DBMS_JOB.SUBMIT( JOB OUT BINARY_INTEGER,
WHAT IN VARCHAR2, NEXT_DATE IN DATE DEFAULTSYSDATE,
INTERVAL IN VARCHAR2 DEFAULT ‘NULL’,
NO_PARSE IN BOOLEAN DEFAULT FALSE,
INSTANCE IN BINARY_INTEGER DEFAULT ANY_INSTANCE,
FORCE IN BOOLEAN DEFAULT FALSE)

Здесь WHAT — это SQL-оператор иди неименованный блок PL/SQL
А ‘Text to be inserted into Exam’ ни то ни другое :)

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

Вместо ‘ » ‘ поставь ‘ ‘ ‘ ‘. Он у тебя не может найти переменную «Text to be inserted into Exam»
Поможет я думаю ;)

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

«В чем же дело ?»

Дело в том, что аккуратней надо код писать.
Что за фигню ты передаёшь?

‘Test_pipe(‘ || st || ‘,’ || ‘»‘ || text || ‘»‘ || ‘)’

Тебе нужно передать значение ‘1000000,Text to be inserted into Exam’?
Тогда так:

declare 

-- Local variables here 


st number := 1000000; 

text varchar2(100) := 'Text to be inserted into Exam'; 

begin 

Run_Proc( Test_pipe(st||','||text) ); 

end; 

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

  • Страница:
  • 1
  • 2

Время создания страницы: 0.386 секунд

Ваш аккаунт

Разделы

Понравилась статья? Поделить с друзьями:
  • Error reading data from radio not the amount of data we want перевод
  • Error reading data 12175 произошла ошибка безопасности faceit ac
  • Error reading data 12002
  • Error reading configuration data wincc
  • Error reading combobox1