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 » IsNumeric

Post new topic  Reply to topic
 IsNumeric « View previous topic :: View next topic » 
Author Message
rons
PostPosted: Mon Jan 20, 2003 1:58 pm    Post subject: IsNumeric Reply with quote

Newbie

Joined: 20 Jan 2003
Posts: 3

Does anyone have some source code to check an ASCII string (after triming it for spaces) to see if it is numeric? I did not see where MQSI had the IsNumeric funciton. I am a newbie. Thanks in advance.

Last edited by rons on Mon Jan 20, 2003 4:56 pm; edited 1 time in total
Back to top
View user's profile Send private message
yaakovd
PostPosted: Mon Jan 20, 2003 2:30 pm    Post subject: Reply with quote

Partisan

Joined: 20 Jan 2003
Posts: 319
Location: Israel

You can convert your string to integer and back, and compare source string with new one.
_________________
Best regards.
Yaakov
SWG, IBM Commerce, Israel
Back to top
View user's profile Send private message Send e-mail
rons
PostPosted: Mon Jan 20, 2003 5:02 pm    Post subject: IsNumeric Reply with quote

Newbie

Joined: 20 Jan 2003
Posts: 3

Wouldn't it give me an error trying to convert it to Integer?
Back to top
View user's profile Send private message
yaakovd
PostPosted: Tue Jan 21, 2003 6:09 am    Post subject: Reply with quote

Partisan

Joined: 20 Jan 2003
Posts: 319
Location: Israel

It wil be problem when casting to integer...
You can try this trick (only in case when it appears ones in input message):
In filter node : IF( CAST(Root.<your path> AS INT))
Connect true, false and unknown connectors to your regular node and failer connector to another node when messages with non-integer will processed.
Or you can use this (tested) code:
---------------------------------------------------------
DECLARE I INT;
DECLARE TMP_C CHAR;
DECLARE TMP_C1 CHAR;
DECLARE FLAG BOOLEAN;
SET FLAG = TRUE;
SET TMP_C = InputRoot.XML."Data" ; -- change to <your path>

SET I = 1;
WHILE(I <= LENGTH(TMP_C)) DO
SET TMP_C1 = SUBSTRING(TMP_C FROM I FOR 1);
IF(TMP_C1 < '0' OR TMP_C1 > '9') THEN
SET FLAG = FALSE;
END IF;
SET I = I +1;
END WHILE;
------------------------------------------------------
In MQSI 2.1 you can create procedure isInteger with this code
_________________
Best regards.
Yaakov
SWG, IBM Commerce, Israel
Back to top
View user's profile Send private message Send e-mail
rons
PostPosted: Tue Jan 21, 2003 6:34 am    Post subject: IsNumeric Reply with quote

Newbie

Joined: 20 Jan 2003
Posts: 3

Thanks yaakovd for your help. The code is exactly what I was looking for. I just need to make a procedure out of it, since I will be checking multiple fields.
Back to top
View user's profile Send private message
yaakovd
PostPosted: Tue Jan 21, 2003 10:21 am    Post subject: Reply with quote

Partisan

Joined: 20 Jan 2003
Posts: 319
Location: Israel

Any time

I also tried:

SUBSTRING('<largest number value>' || STR FROM LENGTH(STR)-1 FOR 19) and compare it with largest integer number (some 19-digits number you can find its value in ESQL reference)

or

SUBSTRING('9999999999999999999' || STR FROM LENGTH(STR)-1 FOR 19) and compare it with '9999999999999999999' etc..

You cat try in this direction...
_________________
Best regards.
Yaakov
SWG, IBM Commerce, Israel
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IsNumeric
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.