The following sql statements return different results from between DB2LUW/ORACLE/... AND DB2ZOS. Could anyone help to explain why no row returned from DB2ZOS(it's supposed to be returned?)? AFAIK, in other databases, it compares the ascii code of the character.
select 'TEST' AS TEST from sysibm.sysdummy1 WHERE 'a' > '3'
select 'TEST' AS TEST from sysibm.sysdummy1 WHERE 'a' > 'A'
The following sql executes correctly:
select 'TEST' AS TEST from sysibm.sysdummy1 WHERE 'a' > 'b'
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
3 replies Latest Post - 2012-11-20T02:38:18Z by SystemAdmin
Pinned topic How DB2ZOS Compares char/varchar
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-11-20T02:38:18Z at 2012-11-20T02:38:18Z by SystemAdmin
ToddBurchDB2 270001F7F874 PostsACCEPTED ANSWER
Re: How DB2ZOS Compares char/varchar2012-11-19T13:37:51Z in response to SystemAdminWhat gets returned depends on the character encoding you are using. On z/OS, it appears your character encoding is EBCDIC, not ASCII.
In EBCDIC, reference the following hex codes to explain your results:
a = 0x81
b = 0x82
A = 0xC1
3 = 0xF3
So, you are getting the correct results using the character encoding you have chosen.
Try the following and see what you get: ;)
select 'TEST' AS TEST from sysibm.sysdummyu WHERE 'a' > '3'
select 'TEST' AS TEST from sysibm.sysdummyu WHERE 'a' > 'A'
Re: How DB2ZOS Compares char/varchar2012-11-20T02:38:18Z in response to ToddBurchDB2I just learned from the Information Center that sysdummy1 and sysdummyu reside in tablespaces with different encoding(SYSTSUNI and SYSEBCDC).
So, no matter what encoding the database is set with, the example SQLs always return the same results.
But if the table is an user created table, that matters.