What types of expressions are allowed for declaring a scalar variable's size in a PL/SQL package?
Here is a db<>fiddle showing size expressions other than numeric literals where some produce errors and others don't. Below is a snippet.
create or replace package p as
vc varchar2(length('four'));
end;
/
Package created.
but
create or replace package p as
vc varchar2(greatest(3,4)); --PLS-00491: numeric literal required
end;
/
ORA-24344: success with compilation error
The previous example with length()
shows that expressions other than numeric literal are allowed.
Both length()
and greatest()
are SQL functions. Why does one function invoke PLS-00491
and the other does not?
Note: The syntax for specifying the size of PL/SQL datatype
does not seem to be provided in the documentation Scalar Variable Declaration.
Using Oracle 19c Enterprise Edition.
Thanks in advance.