Entering content frame

 Converting Data Types 

If, in an embedded SQL statement, the C/C++ basic data type or the UNICODE data type of a parameter does not correspond to the MaxDB data type of the corresponding table column, but can be converted, then the precompiler runtime environment converts the data types at runtime of the application program.

The following tables show the possible conversions, and the errors that can occur:

C/C++ Basic Data Types

MaxDB Data Types

FIXED

FLOAT

BOOLEAN

LONG

CHAR

VARCHAR

DATE/TIME

short int, int,
long int

1,2

1b,2

6

Not permitted

4,5

Not permitted

Not permitted

float, double, long float

1a,2

2

6

Not permitted

4,5

Not permitted

Not permitted

char [n]

4,5

4,5

Not permitted

3

3

3

3

char

4,5

4,5

Not permitted

Not permitted

3

3

3

 

UNICODE Data Types

MaxDB Data Types

FIXED

FLOAT

BOOLEAN

LONG

CHAR

VARCHAR

DATE/TIME

SQLUCS2 [n],
SQLUTF16 [n],
TCHAR [n]

4,5,7

4,5,7

Not permitted

3,7

3,7

3,7

3,7

SQLUCS2,
SQLUTF16,
TCHAR

4,5,7

4,5,7

Not permitted

3,7

3,7

3,7

3,7

 

1    An overflow can occur ( sqlcode < 0).

1a  An overflow can occur when a value is transferred to the database table.

1a  An overflow can occur when a value is transferred to the host variable.

2    Some decimal places may be cut off (indicator value > 0).

3    Some characters may be cut off. The warning message sqlwarn1 is set. The indicator value specifies the actual length of the character string.

4    An overflow can occur when numerical values are converted into character strings ( sqlcode < 0).

5    An overflow or invalid number can occur when character strings are converted into numerical values ( sqlcode < 0).

6    The value 0 is mapped to false. All values other than 0 are mapped to true.

7    An error message is written when UNICODE values are converted that cannot be translated to 8 bit ASCII ( sqlcode < 0).

See also: Database System Messages

 

 

Leaving content frame