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 » General IBM MQ Support » Esql : read a string and findout if it has an integer inside

Post new topic  Reply to topic
 Esql : read a string and findout if it has an integer inside « View previous topic :: View next topic » 
Author Message
kevinmark99
PostPosted: Wed May 22, 2013 5:56 am    Post subject: Esql : read a string and findout if it has an integer inside Reply with quote

Newbie

Joined: 29 Mar 2013
Posts: 8

I am a newbie in ESQL,

I am trying to findout if its possible to findout if

kevinmark99@yahoo.com has a number in it ; i can split and extract out "99" as String, but i need to determine if its a string or int can anyone help me out on this?
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 22, 2013 6:10 am    Post subject: Re: Esql : read a string and findout if it has an integer in Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

kevinmark99 wrote:
i can split and extract out "99" as String, but i need to determine if its a string or int can anyone help me out on this?


Cast the extracted string to an integer with a nonsensical default value, and then check for the nonsensical value.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Thu May 23, 2013 1:07 am    Post subject: Re: Esql : read a string and findout if it has an integer in Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

Vitor wrote:
Cast the extracted string to an integer

Either you cast to INT, or (if you want to avoid the exception) use a utility function:

Code:
containsCharsOnly( extractedString, '0123456789' );


Code:
   CREATE PROCEDURE containsCharsOnly ( IN string CHAR, IN chars CHAR ) RETURNS BOOLEAN
   BEGIN
      DECLARE length1 INT LENGTH( string );
      DECLARE i INT 1;
      WHILE i <= length1 DO
         DECLARE char1 CHAR SUBSTRING( string FROM i FOR 1 );
         IF POSITION( char1 IN chars ) = 0 THEN -- Found something else than the chars in 'chars'
            RETURN FALSE;
         END IF;
         SET i = i + 1;
      END WHILE;
      RETURN TRUE;
   END;

_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu May 23, 2013 4:03 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Delete all characters that are 0-9.

If the string is not empty, it's not an integer.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Thu May 23, 2013 5:40 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

mqjeff wrote:
Delete all characters that are 0-9.

If the string is not empty, it's not an integer.

There are many ways... a... skinny cat... may go.

But one may be faster and the other slower.
_________________
Just use REFERENCEs
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 » General IBM MQ Support » Esql : read a string and findout if it has an integer inside
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.