PL/SQL User's Guide and Reference

Contents Index Home Previous Next

Guidelines

In a given execution environment, whether CHAR is equivalent to VARCHAR2 or not is determined by a command or option that sets Oracle Version 6 or Oracle7 compatibility. For example, in the SQL*Plus environment, you issue the SET COMPATIBILITY command, specifying the value V6 or V7 (the default), as follows:

SQL> SET COMPATIBILITY V6

As the next example shows, in the Oracle Precompiler environment, you enter the runtime option DBMS on the command line, specifying the value V6, V7, or NATIVE (the default). NATIVE specifies the version of Oracle resident on your system, which must be version 6 or later.

... DBMS=V6

When selecting data over a V7-to-V6 link, use VARCHAR2 variables in the WHERE clause instead of CHAR variables. Otherwise, you might get an unsupported network datatype error.

When inserting character values, you can ensure that no trailing blanks are stored by using the RTRIM function, which trims trailing blanks. An example follows:

my_empno := 7471;
my_ename := 'LEE   ';  -- note trailing blanks
...
INSERT INTO emp
   VALUES (my_empno, RTRIM(my_ename), ...);  -- inserts 'LEE'


Contents Index Home Previous Next