DB2 Server for VSE & VM: Application Programming


Defining DB2 Server for VSE & VM Data Types for C


Figure 115. DB2 Server for VSE & VM Data Types for C
Description
DB2 Server for VSE
& VM
Keyword


Equivalent C
Declaration

A binary integer of 31 bits, plus sign. INTEGER or INT
long or


long int

A binary integer of 15 bits, plus sign. SMALLINT
short or


short int

A packed decimal number, precision p, scale s (1<=p<=31 and 0<=s<=p). In storage, the number occupies a maximum of 16 bytes. Precision is the total number of digits. Scale is the number of those digits that are to the right of the decimal point.
DECIMAL[(p[,s])]


or DEC[(p[,s])]
1


decimal(p,s)


If your version of the C
compiler does not provide
support for the decimal
data type, C short, long,
float and double host
variables are supported
for conversion to and
from DECIMAL columns.


To preserve decimal places: if


p<7 use float;


else use double.

A single-precision (4-byte) floating-point number, in short System/390 floating-point format.
REAL or


FLOAT(p),
1 <= p <= 21

FLOAT
A double-precision (8-byte) floating-point number, in long System/390 floating-point format.
FLOAT or


FLOAT(p),
22 <= p <= 53


or DOUBLE
PRECISION

DOUBLE
A fixed-length character string of length 1. CHARACTER[(1)] or CHAR[(1)] char or char ..[1]
A NUL-terminated character string of maximum defined length n. Range of n is 1 <= n <= 254. The terminating NUL is mandatory upon input. VARCHAR(n) char ..[n+1]
A NUL-terminated character string of maximum defined length of 32 767 bytes, subject to certain usage limitations. Range of n is 255 <= n <= 32 766. The terminating NUL is mandatory upon input. LONG VARCHAR char ..[n+1]
A varying-length character string of maximum length n. If n > 254 or <= 32 767, this data type is considered a long field. See Using Long Strings for more information. VARCHAR(n) struct { short ..; char ..[n]; }
A varying-length character string of maximum length 32 767 bytes, subject to certain usage limitations. LONG VARCHAR struct { short ..; char ..[n]; }
A fixed-length string of n DBCS characters where 0 < n <= 127. GRAPHIC[(n)] Not supported
A varying-length string of n DBCS characters. If n > 127 or <= 16 383, this data type is considered a long field. See Using Long Strings for more information. VARGRAPHIC(n) Not supported
A varying-length string of DBCS characters of maximum length 16 383, subject to certain usage limitations. LONG VARGRAPHIC Not supported
A NUL-terminated or varying-length character string representing a date. DATE see VARCHAR(n)
A NUL-terminated or varying-length character string representing a time. TIME see VARCHAR(n)
A NUL-terminated or varying-length character string representing a timestamp. TIMESTAMP see VARCHAR(n)

Notes:

  1. NUMERIC is a synonym for DECIMAL, and may be used when creating or altering tables. In such cases, however, the CREATE or ALTER function will establish the column (or columns) as DECIMAL.

  2. For a NUL-terminated string, the declared length should be one more than the maximum length of a datetime to allow for the terminating NUL-byte, which is mandatory input. Refer to the DB2 Server for VSE & VM SQL Reference manual for information on minimum and maximum lengths.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]