Monday, October 27, 2008

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

Always check out the original article at http://www.oraclequirks.com for latest comments, fixes and updates.

PLS-00363: expression '%s' cannot be used as an assignment target
where %s is a placeholder for the actual string that applies to the particular case.

Oracle raises this error at compilation time when it detects an unsuitable parameter type in the parameter list of a procedure or function call, as in the following cases (the list i give here is presumably a sub-set of all possible situations):

case #1

declare
c_val constant varchar2(10) := 'test';
begin
test_proc(c_val); -- test_proc's parameter is declared as IN/OUT,
-- but c_val is a constant
end;

ORA-06550: line 4, column 11:
PLS-00363: expression 'C_VAL' cannot be used as an assignment target
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored

case #2

create or replace procedure test_proc2 (p_in in varchar2) is
begin
test_proc(p_in); -- test_proc's parameter is IN/OUT,
-- but p_in is an IN parameter of the calling procedure
end;

PLS-00363: expression 'P_IN' cannot be used as an assignment target

case #3

begin
test_proc(10); -- test_proc's parameter is IN/OUT,
-- but you are passing a literal value
end;

ORA-06550: line 2, column 11:
PLS-00363: expression '10' cannot be used as an assignment target
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored

The same error is raised in the previous situations if procedure's parameter is declared as OUT instead of IN/OUT.

case #4
declare
rtn_val constant varchar2(10) := 'test';
begin
rtn_val := test_fn('silly case'); -- cannot assign function's result to a constant
end;

ORA-06550: line 4, column 3:
PLS-00363: expression 'RTN_VAL' cannot be used as an assignment target
ORA-06550: line 4, column 3:
PL/SQL: Statement ignored

however we could use the function to initialize the constant value inside the declaration:
declare
rtn_val constant varchar2(10) := test_fn('silly case');
begin
dbms_output.put_line(rtn_val);
end;
Needless to say, assigning a value to a constant inside the program body is forbidden in all cases as it is a nonsense. Constants must be always initialized with some value in the declaration section.

See message translations for PLS-00363 and search additional resources.

No comments:

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles