Updated on 2024-05-07 GMT+08:00

VAR

Function

Assigns a new C data type to a host variable. The host variable must have been declared in a DECLARE segment.

  • Exercise caution when using VAR. Using VAR to change the data type my cause the memory address to be invalid. As a result, the data variable is invalid and the value cannot be assigned.
  • If the data type has been defined in the host variable DECLARE segment, you do not need to use the VAR statement.

Syntax

VAR varname IS ctype

Parameter Description

  • varname

    Name of a C variable.

  • ctype

    C type description.

Example

EXEC SQL BEGIN DECLARE SECTION; 
    short a;
EXEC SQL END DECLARE SECTION;
EXEC SQL VAR a IS int;