Declaration of fixed-length, null-terminated and variable-length character host variables in C and C++ embedded SQL applications
There are two forms
of C and C++ variables that you can declare in an embedded SQL application.
Form 1 variables are fixed length and null-terminated character host
variables and form 2 are variable-length character host variables.
Variable-Length Character Host Variable Considerations:
- Although the database manager converts character data to either form 1 or form 2 whenever possible, form 1 corresponds to column types CHAR or VARCHAR, whereas form 2 corresponds to column types VARCHAR and LONG VARCHAR.
- If form 1 is used with a length specifier [n], the value for the length specifier after evaluation must be no greater than 32 672, and the string contained by the variable should be null-terminated.
- If form 2 is used, the value for the length specifier after evaluation must be no greater than 32 700.
- In form 2, var1 and var2 must be simple variable references (no operators), and cannot be used as host variables (varname is the host variable).
- varname can be a simple variable name, or it can include operators such as *varname. See the description of pointer data types in C and C++ for more information.
- The precompiler determines the SQLTYPE and SQLLEN of all host variables. If a host variable appears in an SQL statement with an indicator variable, the SQLTYPE is assigned to be the base SQLTYPE plus one for the duration of that statement.
- The precompiler permits some declarations which are not syntactically valid in C or C++. Refer to your compiler documentation if in doubt about a particular declaration syntax.