PLS-00215: String length constraints must be in range (1 .. 32767)

4.2k Views Asked by At

I have a oracle package and there is a function in it which is having out parameters.

the package name lets say ppp and function name lets say fff. function is below and i am unable to execute the function with out parameters.

function-

FUNCTION  fff (P_FID NUMBER,DUCTBANKLABEL VARCHAR2, SERVICEDUCTVALID OUT NUMBER ) RETURN VARCHAR2
----End of R3 - Obs#195 (1 Oct 2018)
AS

CNT NUMBER;
INSTDATE VARCHAR2(100);
DUCTSIZE NUMBER;
.
.
.
.
many more.......;
BEGIN
.
.
.function does its thing and returns the value

END;

Now am trying to call this function with a pl/sql block like this-

set serveroutput on;
declare
aa NUMBER:=129685933;
bb VARCHAR2:='1705297E TO P5547635';
cc  NUMBER;
ANS VARCHAR2;
BEGIN
ANS:=ppp.fff(aa,bb,cc);
DBMS_OUTPUT.put_line(ANS);
END;

But getting the below error-

Error report:
ORA-06550: line 3, column 4:
PLS-00215: String length constraints must be in range (1 .. 32767)
ORA-06550: line 5, column 5:
PLS-00215: String length constraints must be in range (1 .. 32767)
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

Please help on how can i execute this function

2

There are 2 best solutions below

1
On

You need to specify VARCHAR2 variable lengths in your anonymous PL/SQL block.

DECLARE
    aa    NUMBER := 129685933;
    bb    VARCHAR2 (30) := '1705297E TO P5547635';
    cc    NUMBER;
    ANS   VARCHAR2 (200);
BEGIN
    ANS := ppp.fff (aa, bb, cc);
    DBMS_OUTPUT.put_line (ANS);
END;
11
On

varchar2 variables need to have a length as the error indicates.

Line 3

bb VARCHAR2:='1705297E TO P5547635';

and line 5

ANS VARCHAR2;

are both missing lengths. Assuming you want both to allow, say, 100 characters

bb VARCHAR2(100):='1705297E TO P5547635';
ANS VARCHAR2(100);