Troubleshooting
Problem
CHAR parameters of a PL/SQL procedure default to a maximum length of 254 if no length is specified which differs from Oracle
Symptom
In a PL/SQL procedure that has a parameter type that is CHAR, DB2 will default to the maximum length of CHAR(254) if no length is specified. The following VARCHAR2 and CHAR value will not match as the CHAR value will have spaces appended after the text up to the maximum length of 254 characters.
create table T2 (STR1 varchar2(50));
insert into T2 values('test1');
create procedure TEST_PROC(CHARPARAM char)
is
cursor CRSTEST
is select count(1) from T2 where STR1 = CHARPARAM;
..
call TEST_PROC('test1');
This differs from Oracle which acquires the length of the CHAR argument such that no spaces are padded. In Oracle, the above query will be able to match the CHAR value to the VARCHAR2 value.
To view more of this document
Was this topic helpful?
Document Information
More support for:
Db2 for Linux, UNIX and Windows
Software version:
9.7
Operating system(s):
AIX, HP-UX, Linux, Solaris, Windows
Document number:
433885
Modified date:
30 April 2025
UID
swg21514949