Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String range is correct, why still get PLS-00215: String length constraints must be in range (1 ..32767)

Tags:

plsql

CREATE FUNCTION GET_NAME( V_CODE VARCHAR2) RETURN VARCHAR2
AS
    NAME VARCHAR2(242);
BEGIN
    SELECT DISTINCT FACT_NAME
    INTO NAME
    FROM TABLEXXX
    WHERE FACT_CODE = V_CODE;
RETURN NAME;
END;

Why even defined VARCHA2 with length 242, it still shows this error? Too strange.

String length constraints must be in range (1 .. 32767)

like image 893
Erica Zhang Avatar asked Aug 13 '15 09:08

Erica Zhang


1 Answers

It should look like this:

CREATE FUNCTION GET_NAME( PV_CODE VARCHAR2) RETURN VARCHAR2
    AS
        LV_NAME VARCHAR2(242);
    BEGIN
        SELECT DISTINCT NAME
        INTO LV_NAME
        FROM TABLEXXX
        WHERE NAME_CODE = PV_CODE;
    RETURN LV_NAME;
    END;
/

You should use prefix before each variable because they causing conflicts.

like image 72
Caroline Avatar answered Oct 17 '22 22:10

Caroline