473,408 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

String comparison in DB2

Hi All,

I created a table with only one char(1) column and inserted values
from 'A' to 'Z'. After that I am executing "select * from tablename
where colname between '0' and 'z'. It gives me all the data except
'Z' (capital Z). As I am not getting 'Z', it makes me wonder how does
DB2 compare the strings (converts it into ascii or ebcdic or something
else?) ? Anyone has an idea?

Thanks.
Jun 27 '08 #1
5 8095
"spider007" <sa*****************@gmail.comwrote in message
news:08**********************************@s21g2000 prm.googlegroups.com...
Hi All,

I created a table with only one char(1) column and inserted values
from 'A' to 'Z'. After that I am executing "select * from tablename
where colname between '0' and 'z'. It gives me all the data except
'Z' (capital Z). As I am not getting 'Z', it makes me wonder how does
DB2 compare the strings (converts it into ascii or ebcdic or something
else?) ? Anyone has an idea?

Thanks.
What operating system is DB2 running on, and what operating system is the
client running on? Also, it is generally a good idea to specify DB2 version
and fixpack you are using when asking a question, although it may not apply
to this question.
Jun 27 '08 #2
On Jun 19, 3:55 pm, "Mark A" <nob...@nowhere.comwrote:
"spider007" <saurabh.saurabhj...@gmail.comwrote in message

news:08**********************************@s21g2000 prm.googlegroups.com...
Hi All,
I created a table with only one char(1) column and inserted values
from 'A' to 'Z'. After that I am executing "select * from tablename
where colname between '0' and 'z'. It gives me all the data except
'Z' (capital Z). As I am not getting 'Z', it makes me wonder how does
DB2 compare the strings (converts it into ascii or ebcdic or something
else?) ? Anyone has an idea?
Thanks.

What operating system is DB2 running on, and what operating system is the
client running on? Also, it is generally a good idea to specify DB2 version
and fixpack you are using when asking a question, although it may not apply
to this question.
I thought this was regarding the SQL, so didnt mention it. Anyways, i
am running 9.5 on Windows XP
Jun 27 '08 #3
"spider007" <sa*****************@gmail.comwrote in message
news:7c**********************************@u36g2000 prf.googlegroups.com...
I thought this was regarding the SQL, so didnt mention it. Anyways, i
am running 9.5 on Windows XP
I don't think there would be ebcdic involved on DB2 for Windows, only ascii.
But you can check the database configuration for the ALT_COLLATE value.

What does the data look like when you select all the rows in the table
without a where clause, or with = 'Z'?

Jun 27 '08 #4
On Jun 19, 4:35 pm, "Mark A" <nob...@nowhere.comwrote:
"spider007" <saurabh.saurabhj...@gmail.comwrote in message

news:7c**********************************@u36g2000 prf.googlegroups.com...
I thought this was regarding the SQL, so didnt mention it. Anyways, i
am running 9.5 on Windows XP

I don't think there would be ebcdic involved on DB2 for Windows, only ascii.
But you can check the database configuration for the ALT_COLLATE value.

What does the data look like when you select all the rows in the table
without a where clause, or with = 'Z'?
If I select all the values (select *), it shows me all the records
along with 'Z', however, if I mention a where clause, it does not show
'Z'. Here are the command which I executed:

db2 " insert into sj3 values ('A'),('B'),('C'),('X'),('Y'),('Z') "

db2 " select * from sj3 where a between '0' and 'z' "
A
-
A
B
C
X
Y

5 record(s) selected.

I just tried the same on 9.1 FP3 on Linux, and I got the o/p as
expected, meaning I am getting 'Z' with the above query. So it is
depending on the OS, but what is the difference?
Jun 27 '08 #5
spider007 wrote:
On Jun 19, 4:35 pm, "Mark A" <nob...@nowhere.comwrote:
>"spider007" <saurabh.saurabhj...@gmail.comwrote in message

news:7c**********************************@u36g200 0prf.googlegroups.com...
>>I thought this was regarding the SQL, so didnt mention it. Anyways,
i am running 9.5 on Windows XP

I don't think there would be ebcdic involved on DB2 for Windows,
only ascii. But you can check the database configuration for the
ALT_COLLATE value.

What does the data look like when you select all the rows in the
table without a where clause, or with = 'Z'?

If I select all the values (select *), it shows me all the records
along with 'Z', however, if I mention a where clause, it does not show
'Z'. Here are the command which I executed:

db2 " insert into sj3 values ('A'),('B'),('C'),('X'),('Y'),('Z') "

db2 " select * from sj3 where a between '0' and 'z' "
A
-
A
B
C
X
Y

5 record(s) selected.

I just tried the same on 9.1 FP3 on Linux, and I got the o/p as
expected, meaning I am getting 'Z' with the above query. So it is
depending on the OS, but what is the difference?
Read up on "collating sequence" here:
http://publib.boulder.ibm.com/infoce...d/c0006812.htm

In your case the coll. seq. on your Windows box is probably configurated
such that lowercase 'z' sorts lower as uppercase 'Z'.

HTH

--
Jeroen
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: David Graham | last post by:
Hi I have been busy going through the last weeks postings in an attempt to absorb javascript syntax (I guess it's not possible to just absorb this stuff in a passive way - I'm getting way out of...
2
by: Neil Zanella | last post by:
Hello, Consider the following program. There are two C style string stack variables and one C style string heap variable. The compiler may or may not optimize the space taken up by the two stack...
8
by: Grant Wagner | last post by:
I'm a bit confused by String() (typeof 'string') vs new String() (typeof 'object'). When you need to access a method or property of a -String-, what type is JavaScript expecting (or rather, what...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
46
by: yadurajj | last post by:
Hello i am newbie trying to learn C..I need to know about string comparisons in C, without using a library function,...recently I was asked this in an interview..I can write a small program but I...
5
by: MaSTeR | last post by:
Can anyone provide a practical short example of why in C# I shouldn't compare two strings with == ? If I write this in JAVA String string1 = "Widget"; if (string1 == "Widget") ...
4
by: Peter Kirk | last post by:
Hi I am looking at some code which in many places performs string comparison using == instead of Equals. Am I right in assuming that this will in fact work "as expected" when it is strings...
4
by: Jim Langston | last post by:
Is there any builtin lowercase std::string compare? Right now I'm doing this: if ( _stricmp( AmmoTypeText.c_str(), "GunBullet" ) == 0 ) AmmoType = Item_Ammo_GunBullet; Is there anything the...
26
by: Neville Lang | last post by:
Hi all, I am having a memory blank at the moment. I have been writing in C# for a number of years and now need to do something in VB.NET, so forgive me such a primitive question. In C#, I...
6
by: aznimah | last post by:
hi, i'm work on image comparison. i'm using the similarity measurement which i need to: 1) convert the image into the binary form since the algorithm that i've use works with binary data for the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.