DB2 ZOS String Comparison Problem

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-05-05T14:32:35Z Indexed on 2010/05/05 14:38 UTC
Read the original article Hit count: 289

Filed under:
|
|

I am comparing some CHAR data in a where clause in my sql like this,

where PRI_CODE < PriCode

The problem I am having is when the CHAR values are of different lengths. So if PRI_CODE = '0800' and PriCode = '20' it is returning true instead of false.

It looks like it is comparing it like this

'08' < '20' 

instead of like

'0800' < '20'

Does a CHAR comparison start from the Left until one or the other values end?

If so how do I fix this?

My values can have letters in it so convering to numeric is not an option.

© Stack Overflow or respective owner

Related posts about db2

Related posts about zos