Oracle Error PLS-00363: expression ‘string’ cannot be used as an assignment target

Oracle Error Message

PLS-00363: expression ‘string’ cannot be used as an assignment target

Reason for the Error

Oracle Error PLS-00363: expression’string’ cannot be used as an assignment target is a common error that can occur when working with PL/SQL code in Oracle. This error usually occurs when you try to use an expression as the target of an assignment statement and the expression cannot be assigned a value.

For example,

DECLARE
   num1 NUMBER := 10;
   num2 NUMBER := 20;
   str VARCHAR2(20) := 'Hello';
BEGIN
   str := num1 + num2;
END;

The PL/SQL block in this example attempts to assign the value of num1 + num2 to the variable str. However, num1 + num2 is a numeric expression that cannot be assigned to a VARCHAR2 variable.

Solution

Correct the statement by using a valid assignment target.

You must confirm that the expression used as the assignment statement’s target may accept a value if you want to correct this mistake. You might correct the issue in the example above by changing the str variable’s data type to a numeric type:

DECLARE
   num1 NUMBER := 10;
   num2 NUMBER := 20;
   str NUMBER;
BEGIN
   str := num1 + num2;
END;

You could also change the expression in the assignment statement to return a value of the correct data type:

DECLARE
   num1 NUMBER := 10;
   num2 NUMBER := 20;
   str VARCHAR2(20) := 'Hello';
BEGIN
   str := TO_CHAR(num1 + num2);
END;

In this example, the TO CHAR function is used to convert the numeric expression num1 + num2 to a string value that can be assigned to the str variable.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Oracle Error Message ORA-24328: illegal attribute value Reason for the Error The attribute value passed in is illegal. Solution Consult...
Oracle Error Message ORA-01346: LogMiner processed redo beyond specified reset log scn Reason for the Error LogMiner has detected a...
Oracle Error Message ORA-13241: specified dimensionality does not match that of the data Reason for the Error An error occurred...