MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Character comparison

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Sep 23, 2008 7:11 am    Post subject: Character comparison Reply with quote

Suppose there is a field1 which was defined as an integer in the previous design and now it is defined as char. There is a condition like

Code:
WHERE FIELD1 BETWEEN 100 AND 1000


now since this field is changed to a char now, can I give

Code:
WHERE FIELD1 BETWEEN '0100' AND '1000'

?

Will both the queries return the same result?
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Sep 23, 2008 9:01 am    Post subject: Reply with quote

F0C1C2C3 is between F0F1F0F0 and F1F0F0F0.

'0ABC' is between '0100' and '1000'

If you don't quit and go work someplace where they know something about db2, suggest you CAST your column to a numeric datatype within the where clause
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Tue Sep 23, 2008 2:11 pm    Post subject: Reply with quote

Good point, dbz. One minor correction though, '0ABC' is not between '0100' and '1000', but the point is still valid because values like '02AB' and '1ABC' are. The other point is format. Leading/trailing zeroes or spaces. Left/right justified. If these are id's, like account number or policy number, the char definition probably makes sense. The op just needs to understand and enforce the rules used to generate the id's. If this post is for true numeric values, follow dbz's advice.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Sep 24, 2008 5:08 am    Post subject: Reply with quote

jsharon1248,

hast Du recht. ich hab' was falsh gesagt!
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group