ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » checking a element for numeric and alphabets

Post new topic  Reply to topic
 checking a element for numeric and alphabets « View previous topic :: View next topic » 
Author Message
Om
PostPosted: Fri Aug 29, 2003 10:11 am    Post subject: checking a element for numeric and alphabets Reply with quote

Novice

Joined: 11 Aug 2003
Posts: 12

Hi,

I need to check each charcater in couple of elements for numeric and alphabets. Currently I am using the following code:

IF ((UCASE(onePos) <> 'A') AND (UCASE(onePos) <> 'B') AND (UCASE(onePos) <> 'C') AND (UCASE(onePos) <> 'D')
AND (UCASE(onePos) <> 'E') AND (UCASE(onePos) <> 'F') AND (UCASE(onePos) <> 'G') AND (UCASE(onePos) <> 'H')
AND (UCASE(onePos) <> 'I') AND (UCASE(onePos) <> 'J') AND (UCASE(onePos) <> 'K') AND (UCASE(onePos) <> 'L')
AND (UCASE(onePos) <> 'M') AND (UCASE(onePos) <> 'N') AND (UCASE(onePos) <> 'O') AND (UCASE(onePos) <> 'P')
AND (UCASE(onePos) <> 'Q') AND (UCASE(onePos) <> 'R') AND (UCASE(onePos) <> 'S') AND (UCASE(onePos) <> 'T')
AND (UCASE(onePos) <> 'U') AND (UCASE(onePos) <> 'V') AND (UCASE(onePos) <> 'W') AND (UCASE(onePos) <> 'X')
AND (UCASE(onePos) <> 'Y') AND (UCASE(onePos) <> 'Z'))
AND ((UCASE(secPos) = 'A') OR (UCASE(secPos) = 'B') OR (UCASE(secPos) = 'C') OR (UCASE(secPos) = 'D')
OR (UCASE(secPos) = 'E') OR (UCASE(secPos) = 'F') OR (UCASE(secPos) = 'G') OR (UCASE(secPos) = 'H')
OR (UCASE(secPos) = 'I') OR (UCASE(secPos) = 'J') OR (UCASE(secPos) = 'K') OR (UCASE(secPos) = 'L')
OR (UCASE(secPos) = 'M') OR (UCASE(secPos) = 'N') OR (UCASE(secPos) = 'O') OR (UCASE(secPos) = 'P')
OR (UCASE(secPos) = 'Q') OR (UCASE(secPos) = 'R') OR (UCASE(secPos) = 'S') OR (UCASE(secPos) = 'T')
OR (UCASE(secPos) = 'U') OR (UCASE(secPos) = 'V') OR (UCASE(secPos) = 'W') OR (UCASE(secPos) = 'X')
OR (UCASE(secPos) = 'Y') OR(UCASE(secPos) = 'Z'))

Being a newbie I afraid I am doing the check very inefficiently and it looks
ugly too.
Is there a better way? Please advise.
Thanks in advance.
_________________
-Om
Back to top
View user's profile Send private message
Craig B
PostPosted: Sat Aug 30, 2003 4:03 am    Post subject: Reply with quote

Partisan

Joined: 18 Jun 2003
Posts: 316
Location: UK

Hi,

Unfortunately there are no built in functions in ESQL to check if a string consists of numeric characters or non-numeric characters. You will need to check your string character by character as you are currently doing. However, you can do this more efficiently than you currently are. Instead of comparing the variables onepos and secpos with every possible Letter or Number you can use the position function to check against all of them. For example :

Code:

DECLARE isCharacter, isNumeric INT;
SET onePos = 'A';
SET secPos = '1';
SET isCharacter = POSITION(onePos IN 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
SET isNumeric = POSITION(secPos IN '0123456789');


The position function will return a value greater than zero if it finds the search string in the main string. It returns zero if it did not find it in the string. So in the code above, if we did POSITION(onePos IN '0123456789') then this would return zero. This would mean that onePos was not a numeric character etc.

You could then define yourself two ESQL functions to test whole strings that would contain similar code to above and check all characters. You many want to put a length check in for the searchstring so you know you are only testing one char at a time. Ie, if your search string accidentally became 'AZ' then this would not match in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

Hope this helps.
_________________
Regards
Craig
Back to top
View user's profile Send private message
kirani
PostPosted: Sat Aug 30, 2003 7:33 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

FYI. In future IBM is planning to extend CAST function which will allow you to check whether it's a numeric or char data. This will really help when it comes to such requirements.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » checking a element for numeric and alphabets
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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.