In PL/SQL V1, the datatypes CHAR
and VARCHAR2
could
be used interchangeably. In versions after V1, the CHAR
datatype
is right padded with blanks.
In PL/SQL V1, this statement:
var1 CHAR(10) := ‘hello’;
. . .is equal to ‘hello’
.
In versions after V1, however, this statement resolves to a total of ten characters:
‘hello ’
To preserve the V1 behavior of CHAR
variables, the conversion
utility replaces all CHAR(n)
declarations with the equivalent
VARCHAR2(n)
statement. In the preceding example, var1 becomes
VARCHAR2(10)
.
The conversion utility also replaces all VARCHAR
statements with
the equivalent VARCHAR2
expression.
Versions after PL/SQL V1 require a length for all VARCHAR2
variables.
If a length is already specified for a CHAR
datatype, the conversion
utility uses that length when replacing the declaration with VARCHAR2
.
For example:
var1 CHAR(10);
. . .is converted to:
var1 VARCHAR2(10);
When the converter detects a CHAR or VARCHAR2
statement without
a string length, it suggests a length of one character. For example:
var2 CHAR;
. . .is converted to:
var2 VARCHAR2(1);
Similarly,
var3 VARCHAR2;
. . .is converted to:
var3 VARCHAR2(1);
If you do not supply a length for a VARCHAR2
declaration, the
compiler generates this error message:
ERROR 215: String length constraint must be in range (1..32767)
About the PL/SQL conversion utility
Copyright © 1984, 2005, Oracle. All rights reserved.