Oracle7 Server SQL Reference
VAR (Embedded SQL)
Purpose
To perform host variable equivalencing, or to assign a specific Oracle7 external datatype to an individual host variable, overriding the default datatype assignment.
Prerequisites
The host variable must be previously declared in the Declare Section of the embedded SQL program.
Syntax
host_variable Keywords and Parameters
is the host variable to be assigned an Oracle7 external datatype.
datatype is an Oracle7 external datatype recognized by the Oracle Precompilers (not an Oracle7 internal datatype). The datatype may include a length, precision, or scale. This external datatype is assigned to the host_variable. For a list of external datatypes, see Programmer's Guide to the Oracle Precompilers.
Usage Notes
Host variable equivalencing is one kind of datatype equivalencing.
You may want to use datatype equivalencing for one of the
following purposes:
- to automatically null-terminate a character host variable
- to store program data as binary data in the database
- to override default datatype conversion
For more information on using the VAR command to perform host variable equivalencing, see Programmer's Guide to the Oracle Precompilers. The Pro*C and Pro*Pascal Precompilers also support the embedded SQL TYPE command for user-defined type equivalencing.
Example
This example equivalences the host variable DEPT_NAME to
the datatype STRING and the host variable BUFFER to the
datatype RAW(2000):
EXEC SQL BEGIN DECLARE SECTION;
...
dept_name CHARACTER(15); -- default datatype is CHAR
EXEC SQL VAR dept_name IS STRING; -- reset to STRING
...
buffer CHARACTER(200); -- default datatype is CHAR
EXEC SQL VAR buffer IS RAW(200); -- refer to RAW
EXEC SQL END DECLARE SECTION;
Related Topics
TYPE command (Embedded SQL)