20

I have a stored procedure in Oracle Database 10g where my input is a varchar2 but I'm having issues getting it to run when the input string is long (not sure of exact length maybe > 8000).

My thought is the 'intext varchar2' (as below) is by default is too small. In other cases where I need a longer string I might define a varchar2 as "intext2 VARCHAR2(32767);" I tried to define the size similarly in the code below but my syntax is incorrect.

create or replace PROCEDURE TESTPROC ( intext IN VARCHAR2

) AS ....

What is the (default) size of the intext varchar2?

Can that size be defined (increased)?

1 Answer 1

42

You cannot specify a size for a VARCHAR2 parameter to a procedure.

The procedure should happily accept strings up to 32k in size (the maximum size of a VARCHAR2 in PL/SQL). If it were a function that was being called from SQL rather than PL/SQL, the limit would be 4k because the maximum size of a VARCHAR2 in SQL is only 4k.

9
  • Justin is this statement true for output parameter also?
    – D.J.
    Commented May 20, 2019 at 15:18
  • @D.J. - out parameters also do not specify a size, yes. Commented May 20, 2019 at 15:28
  • But in my case its failing is there any settings that controls parameter size?
    – D.J.
    Commented May 20, 2019 at 15:33
  • 1
    @D.J. - Can you define "failing"? Since the caller needs to declare a variable to hold the output and that variable has to have a size, it is entirely possible that the procedure is trying to return a string that is larger than the variable the caller has declared. If so, the caller would need to declare a larger variable. You still wouldn't declare a length for the procedure's out parameter Commented May 20, 2019 at 15:36
  • create or replace PROCEDURE USP_TEST(V_OUTPUT OUT VARCHAR2)IS VAR_PLSQL VARCHAR2(32000); TEMP NUMBER; BEGIN FOR REC IN 1..4005 LOOP BEGIN VAR_PLSQL := VAR_PLSQL||', '||REC; END; END LOOP; SELECT VSIZE(VAR_PLSQL) INTO TEMP FROM DUAL; DBMS_OUTPUT.PUT_LINE(TEMP); V_OUTPUT := VAR_PLSQL; END;
    – D.J.
    Commented May 20, 2019 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.