PP2 does not recognize every possible C variable declaration as valid for use in a SQL statement. For those types that have no direct C declaration, runtime processing allows the return of data to one of the other types.
Storage can be dynamically allocated for those data types not directly representable by a C declaration. This is useful when using dynamic SQLDA information returned by the database.
The following table is a list of the equivalent C definitions for the database data types.
Data Type | Declaration | Notes |
---|---|---|
BYTE | No direct equivalent | 1 |
VARBYTE | No direct equivalent | 1 |
CHAR or CHAR (1) | char identifier | |
CHAR (m) | char identifier [m+1]; | 2 |
VARCHAR (m) | VARCHAR identifier [m] | 3 |
TIME | char identifier | 9 |
TIMESTAMP | char identifier | 10 |
DATE | long [int] identifier; | 4 |
DECIMAL (m, n) | No direct equivalent | 5 |
NUMERIC (m, n) | No direct equivalent | 5 |
FLOAT* | float identifier; | |
REAL* | float identifier; | |
DOUBLEPRECISION* | float identifier; | |
FLOAT** | double identifier; | |
REAL** | double identifier; | |
DOUBLE PRECISION** | double identifier; | |
BYTEINT | No direct equivalent | 6 |
SMALLINT | short [int] identifier; | 7 |
INTEGER | long [int] identifier; | 8 |
* single precision
** double precision
Notes
- Data can be returned to any valid host variable, although PP2 performs no data conversion.
- The integer m must be positive, greater than one.
- The integer m must be positive.
PP2 generates a structure with name identifier comprising a short (2 bytes) len field and a character array field arr of length m.
No terminating null is expected or placed into the arr field.
- The database normally returns a DATE type field as integer.
It is possible to return the value in character string format, as long as the length of the receiving field is sufficient.
The DATEFORM=ANSIDATE format returns the DATE type field as CHAR (10).
- Data can be returned to any valid numeric format, provided the value fits into the field specified.
It is possible to allocate sufficient storage dynamically to hold the decimal field.
In this case, the application must provide for the data returned.
- Data can be returned to any valid numeric format, provided the value fits into the specified field.
It is possible to allocate sufficient storage dynamically to hold the byteint field.
In this case, the application must provide for the data returned.
- PP2 allows specification of int identifier for a smallint on those systems where short and int are equivalent.
For a variable and statement it knows about, PP2 issues a warning about the size of the int field on a particular platform.
- PP2 allows specification of int identifier for an integer on those systems where long and int are equivalent.For a variable and statement it knows about, PP2 issues a warning about the size of the int field on a particular platform.The host variable defined as a long data type will be 4 bytes when compiled with the 32-bit compiler option and 8 bytes when compiled with the 64-bit compiler options on the AIX or 64-bit Windows platforms.When generating SQLDA for the static SQL statement, the PP2 precompiler assigns:
- SQLTYPE to the INTEGER data type
- SQLLEN to “sizeof(long)”
- For TIME, the length of the char identifier should be 15.
- For TIMESTAMP, the length of the char identifier should be 35.