Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does an oracle plsql varchar2 variable need a size but a parameter does not?

Suppose you have this procedure:

PROCEDURE f (param VARCHAR2)
IS 
   var VARCHAR2(10);
BEGIN
   var := 'hi';
END f;

I would like to understand why var needs a length specified, but param does not. I'm having a hard time finding information about this in the oracle docs.

like image 384
grinch Avatar asked Feb 26 '14 18:02

grinch


People also ask

What is default size of VARCHAR2 in Oracle?

Without specifying the maximum length for a VARCHAR2 parameter, the default is 4000 bytes.

How does VARCHAR2 work in Oracle?

The VARCHAR2 datatype stores variable-length character strings. When you create a table with a VARCHAR2 column, you specify a maximum column length (in bytes, not characters) between 1 and 2000 for the VARCHAR2 column.

What is difference between VARCHAR and VARCHAR2 in Oracle?

VARCHAR2 is the same as VARCHAR in the oracle database. The main difference is that VARCHAR is ANSI Standard and VARCHAR2 is Oracle standard. The VarChar2 data type is used to store the character values. It is a variable-length data type i.e we can change the size of the character variable at execution time.

What is size of VARCHAR2 data type?

The VARCHAR2 datatype represents variable-length character strings. On most platforms, the maximum length of a VARCHAR2 value is 65535 bytes.


1 Answers

"Oracle Database derives the length, precision, and scale of an argument from the environment from which the procedure is called."

Please check out this related question.

Reference: Oracle® Database SQL Reference 10g Release 2 (10.2) Please look under semantics / argument / datatype.

like image 198
Joseph B Avatar answered Sep 20 '22 15:09

Joseph B