BASED ON

From InterBase

Go Up to Statement and Function Reference (Language Reference Guide)


Declares a host-language variable based on a column. Available in gpre.

 BASED [ON] [<dbhandle>.]<table>.<col>[.SEGMENT] <variable>;
Argument Description

<dbhandle>

Handle for the database in which a table resides in a multi-database program; <dbhandle> must be previously declared in a SET DATABASE statement.

<table.col>

Name of table and name of column on which the variable is based.

.SEGMENT

Bases the local variable size on the segment length of the Blob column during BLOB FETCH operations; use only when <­table.col> refers to a column of BLOB data type.

<variable>

Name of the host-language variable that inherits the characteristics of a database column.

Description: BASED ON is a preprocessor directive that creates a host-language variable based on a column definition. The host variable inherits the attributes described for the column and any characteristics that make the variable type consistent with the programming language in use. For example, in C, BASED ON adds one byte to CHAR and VARCHAR variables to accommodate the NULL character terminator.

Use BASED ON in a variable declaration section of a program.

Note:
BASED ON does not require the EXEC SQL keywords.

To declare a host-language variable large enough to hold a Blob segment during FETCH operations, use the SEGMENT option of the BASED ON clause. The size of the variable is derived from the segment length of a Blob column. If the segment length for the Blob column is changed in the database, recompile the program to adjust the size of host variables created with BASED ON.

Examples: The following embedded statements declare a host variable based on a column:

EXEC SQL
BEGIN DECLARE SECTION
BASED_ON EMPLOYEE.SALARY salary;
EXEC SQL
END DECLARE SECTION;

See Also

Advance To: