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 » How to identify the strting is numeric or not?

Post new topic  Reply to topic
 How to identify the strting is numeric or not? « View previous topic :: View next topic » 
Author Message
javaforvivek
PostPosted: Tue Jul 20, 2004 5:27 am    Post subject: How to identify the strting is numeric or not? Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

Hi I am developing an ESQL module, in which I need to know whether a variable (charatcer datatype) can be casted to a number or not..
what should I do? Has anybody used NaN for this? How to use it?
For e.g,

DECLARE string1 CHARACTER '1234';
DECLARE string2 CHARACTER 'abcd';

Use of CAST (string2 AS DECIMAL) gives me an error.
How to determine by ESQL, that string1 can be casted to number but string2 cannot??
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
RocknRambo
PostPosted: Tue Jul 20, 2004 7:15 am    Post subject: Reply with quote

Partisan

Joined: 24 Sep 2003
Posts: 355

you can scan through the string charecter by charecter to find out whether it is a numeric or not.

try this esql code .. (declaration not completed)

SET CHEK_STRING = TRUE;
WHILE(I <= LENGTH(STRING_NUM_OR_NOT)) DO

SET FIRST_CHAR = SUBSTRING(STRING_NUM_OR_NOT FROM I FOR 1);
IF(FIRST_CHAR < '0' OR FIRST_CHAR > '9') THEN
SET CHEK_STRING = FALSE;
END IF;
SET I = I+1;
END WHILE;

good luck.
-sanu
Back to top
View user's profile Send private message
javaforvivek
PostPosted: Tue Jul 20, 2004 7:35 am    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

Thanks Sanu,
I had thought of this solution at first. But it is a bit cumbersome..
I had read about NAN in ESQL-Help.. Do anybody here know whether NAN can be used here or not? If yes, then how?
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lisa
PostPosted: Tue Jul 20, 2004 7:49 am    Post subject: NAN Reply with quote

Master

Joined: 07 Jun 2002
Posts: 287
Location: NJ

Do you mean MQRO_NAN? These is part of the MQMD header.

Lisa
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Tue Jul 20, 2004 7:53 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

NAN can only be used with numeric data types, not with string data types.

At least, if I understand this properly
Quote:
Operator IS
The operator IS allows you to test whether a value is NULL.

This includes testing values INF, +INF, -INF, NAN (not a number), and NUM in any mixture of case. The alternative forms +INFINITY, -INFINITY, and NUMBER are also accepted.

If applied to non-numeric types, the result is FALSE.

So, if you try to use NAN against a string, it will always be false. I think.

Unless an implicit cast occurs.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
javaforvivek
PostPosted: Tue Jul 20, 2004 8:20 am    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

Jeff,
what you said is correct, and that's why I have to follow the code that Sanu has provided...
Lisa,
sorry, but my question is not about message header parts..
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to identify the strting is numeric or not?
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.