What it means
Db2 checked a value coming from your program and found it could not fit the target. The position number in the message tells you which host variable (for INSERT, UPDATE, MERGE, DELETE, SELECT, VALUES INTO or SET) or which parameter (for CALL or a function) is at fault.
SQLSTATE 22003 means a number was too large for the target. SQLSTATE 22001 covers the other cases, such as a string that is too long or a decimal host variable that does not hold valid packed-decimal data.
Typical causes
- A COMP-3 host variable containing spaces, low-values or other non-numeric bytes.
- A string host variable longer than the column it is stored in.
- A number larger than the column precision allows.
- A copybook out of step with the table definition.
- A host variable at the wrong position because the INTO or VALUES list is misaligned.
How to fix it
- Use the position number in the message to find the host variable or parameter.
- Display its contents in hex to check for invalid packed-decimal data.
- Compare its length and type with the column in SYSIBM.SYSCOLUMNS.
- Initialise numeric fields properly, regenerate declarations with DCLGEN if needed, and rerun.
Example
Illustrative only; names and values are invented.
SQLCODE = -302, SQLSTATE = 22001
-- input variable 3 (WS-DEPT-NAME, 40 bytes) is longer than DEPTNAME VARCHAR(36)