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 » Passing only numeric values

Post new topic  Reply to topic
 Passing only numeric values « View previous topic :: View next topic » 
Author Message
neeha_kashyap120
PostPosted: Wed Dec 23, 2009 7:00 am    Post subject: Passing only numeric values Reply with quote

Apprentice

Joined: 05 Mar 2009
Posts: 31

Hi

I am doing a XML --> XML transformation. One of the source fields can have a value that is either numeric or a combination of numeric and character values. I need to pass only the numeric values and remove the character values.

The characters can occur at any position and in upper or lower case.

Like if the source value is a123bc456, the target value should be 123456.

Can someone help me as to how to find and remove the character values.

Thanks
_________________
Neeharika Kashyap
IBM Certified System Administrator - WebSphere MQ V6.0
Trying to be IBM Certified System Administrator - WebSphere Message Broker V6.1 and IBM Certified Solution Developer - WebSphere Message Broker V6.1
Back to top
View user's profile Send private message
amiivas
PostPosted: Wed Dec 23, 2009 9:07 am    Post subject: Reply with quote

Apprentice

Joined: 14 Oct 2007
Posts: 44
Location: Texas, USA

you can write a function for parsing that string and only taking those characters which are in the range of numeric ascii values. This can easily be done in Java compute node using regex function but for esql, you need to call java function or hardcode the logic. I know this is a work around solution as well as a performance degradation, but take it as a last choice.
_________________
IBM WebSphere Certified Solution Developer
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Dec 23, 2009 9:19 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

amiivas wrote:
you can write a function for parsing that string and only taking those characters which are in the range of numeric ascii values. This can easily be done in Java compute node using regex function but for esql, you need to call java function or hardcode the logic. I know this is a work around solution as well as a performance degradation, but take it as a last choice.


Of course, esql provides several character replacement functions that can be used directly to do this as well, even if not strictly a "regex" function. The TRANSLATE function is a natural choice here.
Back to top
View user's profile Send private message
cool_ziv
PostPosted: Wed Dec 23, 2009 9:28 am    Post subject: Reply with quote

Newbie

Joined: 24 Nov 2009
Posts: 8

You can look into making use of 'Translate' ESQL string funtion.

Did u check any related forum topics here??
May be this might help you.
http://www.mqseries.net/phpBB2/viewtopic.php?t=31859&highlight=translate
Back to top
View user's profile Send private message
cool_ziv
PostPosted: Wed Dec 23, 2009 9:37 am    Post subject: Reply with quote

Newbie

Joined: 24 Nov 2009
Posts: 8

This should do the trick.
TRANSLATE(StringVariable,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','');
or
TRANSLATE(LCASE(StringVariable),'abcdefghijklmnopqrstuvwxyz','');
I used LCASE just to reduce the number of searchstringexpressions.
Back to top
View user's profile Send private message
neeha_kashyap120
PostPosted: Wed Dec 23, 2009 11:04 am    Post subject: Reply with quote

Apprentice

Joined: 05 Mar 2009
Posts: 31

Thanks a lot guys.
I did try with TRANSLATE earlier but I was coding as TRANSLATE(Value,[a-z],'') which was erroring out. I will try this and see if that works.

Neeha
_________________
Neeharika Kashyap
IBM Certified System Administrator - WebSphere MQ V6.0
Trying to be IBM Certified System Administrator - WebSphere Message Broker V6.1 and IBM Certified Solution Developer - WebSphere Message Broker V6.1
Back to top
View user's profile Send private message
amiivas
PostPosted: Wed Dec 23, 2009 11:23 am    Post subject: Reply with quote

Apprentice

Joined: 14 Oct 2007
Posts: 44
Location: Texas, USA

cool_ziv wrote:
This should do the trick.
TRANSLATE(StringVariable,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','');
or
TRANSLATE(LCASE(StringVariable),'abcdefghijklmnopqrstuvwxyz','');
I used LCASE just to reduce the number of searchstringexpressions.


gr8 that will definitely work, nowadays I am working more with Java hence more java oriented...
_________________
IBM WebSphere Certified Solution Developer
Back to top
View user's profile Send private message
neeha_kashyap120
PostPosted: Tue Jan 05, 2010 12:58 pm    Post subject: Checking for all non-numeric characters and removing them Reply with quote

Apprentice

Joined: 05 Mar 2009
Posts: 31

Hi

Thanks to everyone's input in my previous post I was able to remove all teh alphabetic values from a source field. But is there a way to remove any character thats not a number from 0-9. Which may include special characters. Or maybe some way to pass only numbers 0-9.

Thanks in advance
_________________
Neeharika Kashyap
IBM Certified System Administrator - WebSphere MQ V6.0
Trying to be IBM Certified System Administrator - WebSphere Message Broker V6.1 and IBM Certified Solution Developer - WebSphere Message Broker V6.1
Back to top
View user's profile Send private message
ggriffith
PostPosted: Fri Jan 08, 2010 8:37 am    Post subject: Reply with quote

Acolyte

Joined: 17 Oct 2007
Posts: 67

DECLARE inp CHARACTER InputRoot.XMLNSC.Data.str1;
DECLARE temp CHARACTER;
DECLARE outp CHARACTER '';

DECLARE i INTEGER 1;
DECLARE j INTEGER length(inp);

WHILE i <= j DO
SET temp = SUBSTRING(inp FROM i FOR 1);
IF LENGTH(TRANSLATE(temp,'0123456789','')) = 0 THEN
SET outp = outp || temp;
END IF;
SET i = i + 1;
END WHILE;

SET OutputRoot.XMLNSC.Data.str1 = outp;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

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