Native SQL for DB2 Common Server
Below are the conversion tables for ABAP variables and data types in the DB2 Common Server database.
Note: The following documentation refers to the current database release DB2 UDB Version 5.0. SAP cannot accept any responsibility for consistency in other releases. Consistency will only be ensured if the database manufacturer (IBM) itself guarantees that the type conversions will be backward compatible. These tables are not to be regarded as a set of guaranteed conversion rules.
The following abbreviations are used:
Insert/update a variable value of the following ABAP type:
Select a column value with the following database type:
Insert/Update
DB Data Type |
Test case [notes] |
Result |
char |
ABAP data value width > DB column width |
22001 |
ABAP data value width <= DB column width |
ok
| |
varchar |
ABAP data value width > DB column width |
22001 |
ABAP data value width <= DB column width |
ok
| |
decimal |
ABAP data value is non-numeric |
22005 |
Loss of significant figures in conversion |
22003 | |
Loss of non-significant figures |
22003 | |
No loss in conversion |
ok
| |
numeric |
ABAP data value is non-numeric |
22005 |
Loss of significant figures in conversion |
22003 | |
Loss of non-significant figures |
22003 | |
No loss in conversion |
ok
| |
smallint |
ABAP data value is non-numeric |
22005 |
Loss of significant figures in conversion |
22003 | |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
integer |
ABAP data value is non-numeric |
22005 |
Loss of significant figures in conversion |
22003 | |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
float |
ABAP data value is non-numeric |
22005 |
Loss of significant figures in conversion |
22003 | |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
double |
ABAP data value is non-numeric |
22005 |
Loss of significant figures in conversion |
22003 | |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
date |
ABAP data value does not have a valid DB date format |
22007 |
ABAP data value has a valid DB date format |
ok
| |
time |
ABAP data value does not have a valid DB time format |
22007 |
ABAP data value has a valid DB time format |
ok
| |
timestamp |
ABAP data value does not have a valid DB timestamp format |
22007 |
ABAP data value has a valid DB timestamp format |
ok
|
DB Data Type |
Test case [notes] |
Result |
char |
ABAP data value width > DB column width |
22001 |
ABAP data value width <= DB column width |
ok
| |
varchar |
ABAP data value width > DB column width |
22001 |
ABAP data value width <= DB column width |
ok
| |
decimal |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
numeric |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
smallint |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
integer |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
float |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
double |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
date |
|
22007 |
time |
|
22007 |
timestamp |
|
22007 |
ABAP Data Type: Packed Number P
DB Data Type |
Test case [notes] |
Result |
decimal |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
numeric |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
smallint |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
integer |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
float |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
double |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
|
DB Data Type |
Test case [notes] |
Result |
char |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
varchar |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
decimal |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
numeric |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
smallint |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
integer |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
float |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
double |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
date |
|
22007 |
time |
|
22007 |
timestamp |
|
22007 |
DB Data Type |
Test case [notes] |
Result |
char |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
22003 | |
No loss in conversion |
ok
| |
varchar |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
22003 | |
No loss in conversion |
ok
| |
decimal |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
numeric |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
smallint |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
integer |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures |
[ trunc] | |
No loss in conversion |
ok
| |
float |
Loss of significant figures in conversion |
22003 |
No loss in conversion |
ok
| |
double |
Loss of significant figures in conversion |
22003 |
No loss in conversion |
ok
| |
date |
|
22007 |
time |
|
22007 |
timestamp |
|
22007 |
DB Data Type |
Test case [notes] |
Result |
char(8) |
ABAP data value width (8) > DB column width |
22001 |
ABAP data value width (8) <= DB column width |
ok
| |
varchar |
ABAP data value width (8) > DB column width |
22001 |
ABAP data value width (8) <= DB column width |
ok
| |
decimal |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
numeric |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
smallint |
[Data is always lost] |
22003 |
integer |
|
ok
|
float |
|
ok
|
double |
|
ok
|
date |
|
22007 |
time |
|
22007 |
timestamp |
|
22007 |
DB Data Type |
Test case [notes] |
Result |
char(6) |
ABAP data value width (6) > DB column width |
22001 |
ABAP data value width (6) <= DB column width |
ok
| |
varchar |
ABAP data value width (6) > DB column width |
22001 |
ABAP data value width (6) <= DB column width |
ok
| |
decimal |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
numeric |
Loss of figures in conversion |
22003 |
No loss in conversion |
ok
| |
smallint |
[Data is always lost] |
22003 |
integer |
|
ok
|
float |
|
ok
|
double |
|
ok
|
date |
|
22007 |
time |
|
22007 |
timestamp |
|
22007 |
DB Data Type |
Test case [notes] |
Result |
char |
ABAP data value width > DB column width |
22001 |
ABAP data value width = DB column width |
ok
| |
ABAP data value width < DB column width |
[ undef] | |
varchar |
ABAP data value width > DB column width |
22001 |
ABAP data value width = DB column width |
ok
| |
ABAP data value width < DB column width |
[ undef] |
Select
Database Column Type char, varchar, or longvarchar
ABAP Data Type |
Test case [notes] |
Result |
Character C |
Database data value width > ABAP field width |
[ rtrunc] |
Database data value width < ABAP field width |
ok
| |
Database data value width = ABAP field width |
ok
| |
Numeric N |
Database data value is non-numeric |
[ undef] |
Database data value width > ABAP field width |
22sim | |
Database data value width < ABAP field width |
ok
| |
Database data value width = ABAP field width |
ok
| |
Packed P |
[simulated SQL error] |
22sim |
Integer I |
Database data value is non-numeric |
22005 |
Loss of significant figures in conversion |
22003 | |
No loss in conversion |
ok
| |
Float F |
Database data value is non-numeric |
22005 |
Loss of significant figures in conversion |
22003 | |
Loss of non-significant figures in conversion |
[ round] | |
No loss in conversion |
ok
| |
Date D |
Behaves like ABAP type C(8) |
- |
Time T |
Behaves like ABAP type C(6) |
- |
Hexa X |
Database data value width > ABAP field width |
[ rtrunc] |
Database data value width < ABAP field width |
ok
| |
Database data value width = ABAP field width |
ok
|
Database Field Type decimal or numeric
ABAP Data Type |
Test case [notes] |
Result |
Character C |
[simulated SQL error] |
22sim |
Numeric N |
[simulated SQL error] |
22sim |
Packed P |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures in conversion |
[ round] | |
No loss in conversion |
ok
| |
Integer I |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures in conversion |
[ round] | |
No loss in conversion |
OK | |
Float F |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures in conversion |
[ round] | |
No loss in conversion |
ok
| |
Date D |
[simulated SQL error] |
22sim |
Time T |
[simulated SQL error] |
22sim |
Hexa X |
[ undef] |
Database Field Type float or double
ABAP Data Type |
Test case [notes] |
Result |
Character C |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures in conversion |
[ round] | |
No loss in conversion |
ok
| |
Numeric N |
[simulated SQL error] |
22sim |
Packed P |
[simulated SQL error] |
22sim |
Integer I |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures in conversion |
[ round] | |
No loss in conversion |
ok
| |
Float F |
Loss of significant figures in conversion |
22003 |
Loss of non-significant figures in conversion |
[ round] | |
No loss in conversion |
ok
| |
Date D |
[simulated SQL error] |
22sim |
Time T |
[simulated SQL error] |
22sim |
Hexa X |
|
[ undef] |
Database Column Type integer or smallint
ABAP Data Type |
Test case [notes] |
Result |
Character C |
Loss of significant figures in conversion |
22003 |
No loss in conversion |
ok
| |
Numeric N |
[simulated SQL error] |
22sim |
Packed P |
[simulated SQL error] |
22sim |
Integer I |
[No loss in conversion] |
ok
|
Float F |
[No loss in conversion] |
ok
|
Date D |
[simulated SQL error] |
22sim |
Time T |
[simulated SQL error] |
22sim |
Hexa X |
|
[ undef] |
Database Column Type: Date, Time, or Timestamp
ABAP Data Type |
Test case [notes] |
Result |
Character C |
Database data value width > ABAP field width |
22003 |
Database data value width < ABAP field width |
ok
| |
Database data value width = ABAP field width |
ok
| |
Numeric N |
[simulated SQL error] |
22sim |
Packed P |
[simulated SQL error] |
22sim |
Integer I |
[restricted data type attribute violation] |
07006 |
Float F |
[restricted data type attribute violation] |
07006 |
Date D |
[simulated SQL error] |
22sim |
Time T |
[simulated SQL error] |
22sim |
Hexa X |
[restricted data type attribute violation] |
07006 |