select col1, col2, char2hexint(col1), char2hexint(col2),
(case when nvl(TRIM(col1),'0')=nvl(TRIM(col2),'0') then 1 else 0 end) col3
from table1 inner join table2 on (colpi11=colpi22);
col1 col2 hex(col1) hex(col2) col3
CO02558438 CO02558438 434F303235353834333800000000000000000000 434F3032353538343338 0
NULL 0000000000000000000000000000000000000000 NULL 0
a NULL in SQL is not a binary zero.
What you see seems to be a common problem when data is loaded from DB2, it's the so-called "low value". DB2 tends to add those instead of a proper blank '20'xc.
You need to TRIM(TRAILING '00'xc FROM col). But sometimes those low values seem to be within a string, too. So you better use oTRANSLATE(col, '00'xc, '') instead.
Best case would be cleaning the existing data and modifying the load process.