Supported SQL data types in CC

 < Day Day Up > 



Supported SQL data types in C/C++

Table 9-5 provides a complete list of SQL data types, C/C++ data type mapping, and a quick description of each. Note that DB2 UDB has multiple definitions for DATE and multiple types for NUMBER.

Table 9-5: Oracle to DB2 data type mapping
 

SQL data type sqltype

C/C++ type

sqllen

Description

integer

SMALLINT (500 or 501)

short

2

  • 16-bit signed integer

  • range between (-32,768 and 32,767)

  • precision of 5 digits

     
 

INTEGER INT (496 or 497)

long

4

  • 32-bit signed integer

  • range between (-2,147,483,648 and 2,147,483,647)

  • precision of 10 digits

 

BIGINT (492 or 493)

long

8

  • 64-bit signed integer

floating point

REAL FLOAT (480 or 481)

float

 
  • Single precision floating point

  • 32-bit approximation of a real number

  • FLOAT(n) can be synonym for REAL if 0 < n < 25

 

DOUBLE (480 or 481) DOUBLE PRECISION

double

8

  • Double precision floating point

  • 64-bit approximation of a real number

  • Range in (0, -1.79769E+308 to -2.225E-307, 2.225E-307 to 1.79769E+308)

  • FLOAT(n) can be synonym for DOUBLE if 24 < n < 54

decimal

DECIMAL(p,s) DEC(p,s) (484 or 485)

NUMERIC(p,s) NUM(p,s)

double / decimal

p/2+1

  • Packed decimal

  • If precision /scale not specified, default is (5,0)

  • Max precision is 31 digits, and max range between (-10E31 + 1 ... 10E31 -1)

  • Consider using char / decimal functions to manipulate packed decimal fields as char data

date / time

DATE (384 or 385)

 struct {   short len;   char  data[10]; } dt; char dt[11]; 

10

  • Null-terminated character form (11 characters) or varchar struct form (10 characters); struct can be divided as desired to obtain the individual fields

  • Example: 11/02/2000

  • Stored internally as a packed string of 4 bytes

 

TIME (388 or 389)

char

8

  • Null-terminated character form (9 characters) or varchar struct form (8 characters); struct can be divided as desired to obtain the individual fields

  • Example: 19:21:39

  • Stored internally as a packed string of 3 bytes

 

TIMESTAMP

char

26

  • Null-terminated character form (27 characters) or varchar struct form (26 characters); struct can be divided as desired to obtain the individual fields

  • Example: 2003-08-04-01.02.03.0000 00 - Stored internally as a packed string of 10 bytes

character

CHAR (452 or 453)

char

n

  • Fixed-length character string consisting of n bytes

  • Use char[n+1] where 1 <= n <= 254

  • If length not specified, defaults to 1

 

VARCHAR (460 or 461)

char

n

  • Null-terminated variable length character string

  • Use char[n+1] where 1 <= n <=32672

 

VARCHAR (448 or 449)

 struct {   short len;   char data[n ]; } 

len

  • Non null-terminated varying character string with 2-byte string length indicator

  • Use char[n] in struct form where 1<= n <= 32672

  • Default SQL type

 

LONG VARCHAR (456 or 457)

 struct {   short len;   char data[n ]; } 

len

  • Non null-terminated varying character string with 2-byte string length indicator

  • Use char[n] in struct form where 32673<= n <= 32700

 

CLOB(n) (408 or 409)

clob

n

  • Non null-terminated varying character string with 4-byte string length indicator

  • Use char[n] in struct form where 1 <= n <= 2147483647

 

CLOB (964 or 965)

clob_locator

 
  • Identifies CLOB entities residing on the server

 

CLOB (808 or 809)

clob_file

 
  • Descriptor for file containing CLOB data

binary

BLOB(n) (404 or 405)

blob

n

  • Non null-terminated varying binary string with 4-byte string length indicator

  • Use char[n] in struct form where 1 <= n <= 2147483647

 

BLOB (960 or 961)

blob_locator

 
  • Identifies BLOB entities on the server

 

BLOB (804 or 805)

blob_file

 
  • Descriptor for the file containing BLOB data

double- byte

GRAPHIC(1) GRAPHIC(n) (468 or 469)

sqldbchar

24

  • sqldbchar is a single double-byte character string

  • For a fixed-length graphic string of length integer which may range from 1 to 127. If the length specification is omitted, a length of 1 is assumed.

  • Precompiled with CHARTYPE NOCONVERT option

 

VARGRAPHIC( n) (464 or 465)

 struct {   short int;   sqldbchar[n ] } tag; alternately: sqldbchar[n+ 1] 

n*2+ 4

  • For a varying-length graphic string of maximum length integer, which may range from 1 to 16336.

  • Precompiled with WCHARTYPE NOCONVERT option.

  • Null terminated variable-length

 

LONG VARGRAPHIC( n) (472 or 473)

 struct {   short int;   sqldbchar[n ] } tag; 

 
  • For a varying-length graphic string with a maximum length of 16350 and a 2-byte string length indicator 16337<=n <=16350

  • Precompiled with WCHARTYPE NOCONVERT option

 

DBCLOB(n) (412 or 413)

dbclob

 
  • For non-null-terminated varying double-byte character large object string of the specified maximum length in double-byte characters.

  • 4 bytes string length indicator

  • Use dbclob(n) where 1<=n <= 1073741823 double-byte characters.

  • Precompiled with WCHARTYPE NOCONVERT option

 

DBCLOB

dbclob_locat or

 
  • Identifies DBCLOB entities residing on the server

  • Precompiled with WCHARTYPE NOCONVER option

 

DBCLOB

dbclob_file

 
  • Descriptor for file containing DBCLOB data

  • Precompiled with WCHARTYPE NOCONVERT option

external data

Datalink(n)

 

n+54

  • The length of a DATALINK column is 200 bytes

For more information, see the SQL Referencevol 1, SC09-4844; vol 2 - SC09-4845, the Application Development Guide, and the file that is supplied on DB2 clients: sqllib\include\sql.h



 < Day Day Up > 



Oracle to DB2 UDB Conversion Guide2003
Oracle to DB2 UDB Conversion Guide2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net