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.
Without specifying the maximum length for a VARCHAR2 parameter, the default is 4000 bytes.
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.
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.
The VARCHAR2 datatype represents variable-length character strings. On most platforms, the maximum length of a VARCHAR2 value is 65535 bytes.
"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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With