Declaration of numeric host variables in C and C++ embedded SQL applications

Numeric host variables that you declare in your embedded C or C++ application are treated as if they were declared in a C or C++ program. You can use host variables to exchange data between the embedded application and the database manager.

Following is the syntax for declaring numeric host variables in C or C++.

Read syntax diagramSkip visual syntax diagramautoexternstaticregisterconstvolatilefloat1double2short3intINTEGER (SQLTYPE 496)BIGINT (SQLTYPE 492)
INTEGER (SQLTYPE 496)
Read syntax diagramSkip visual syntax diagramsqlint32long4int
BIGINT (SQLTYPE 492)
Read syntax diagramSkip visual syntax diagramsqlint64__int64long longintlong5int
Read syntax diagramSkip visual syntax diagram,*&constvolatilevarname=value;
Notes:
  • 1 REAL (SQLTYPE 480), length 4
  • 2 DOUBLE (SQLTYPE 480), length 8
  • 3 SMALLINT (SQLTYPE 500)
  • 4 For maximum application portability, use sqlint32 for INTEGER host variables and sqlint64 for BIGINT host variables. By default, the use of long host variables results in the precompiler error SQL0402 on platforms where long is a 64 bit quantity, such as 64 BIT UNIX. Use the PREP option LONGERROR NO to force Db2® to accept long variables as acceptable host variable types and treat them as BIGINT variables.
  • 5 For maximum application portability, use sqlint32 and sqlint64 for INTEGER and BIGINT host variables. To use the BIGINT data type, your platform must support 64 bit integer values. By default, the use of long host variables results in the precompiler error SQL0402 on platforms where long is a 64 bit quantity, such as 64 BIT UNIX. Use the PREP option LONGERROR NO to force Db2 to accept long variables as acceptable host variable types and treat them as BIGINT variables.