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 do I check the data type of a variable?

Post new topic  Reply to topic
 How do I check the data type of a variable? « View previous topic :: View next topic » 
Author Message
ccrandall
PostPosted: Fri Oct 02, 2009 7:57 am    Post subject: How do I check the data type of a variable? Reply with quote

Acolyte

Joined: 23 Oct 2008
Posts: 52

I have a situation where I'm adding 10 min to the Expiry in an incoming MQ message to the Output message. The problem is, though, in some instances the Expiry of the input message is sometimes expressed as an INT and other times as a TIMESTAMP.

I've skimmed through the site and the IBM ESQL PDF for MB 6.1 and I didn't see any operator/function that could be used to check a data type. Does such a thing exist? If so, could someone point me in the right direction on this one?

Thanks!
Curt
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Oct 02, 2009 8:40 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

This was discussed recently here

http://www.mqseries.net/phpBB2/viewtopic.php?p=257479

This might answer your question.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
ccrandall
PostPosted: Fri Oct 02, 2009 8:49 am    Post subject: Reply with quote

Acolyte

Joined: 23 Oct 2008
Posts: 52

I did see this and it's close, but I really need to know how to tell an INT from a TIMESTAMP. I thought FIELDTYPE would work, but it doesn't appear to... or else I'm just not using it right.

Thanks
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Oct 02, 2009 10:49 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Try casting the MQMD.Expiry to a character string and then getting its length.
If it is less than say 10 then it is a number otherwise, it is a timestamp.

I'm sure there are other ways but thise seems to be one that is fairly simple.

/Steve
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
ccrandall
PostPosted: Fri Oct 02, 2009 10:56 am    Post subject: Reply with quote

Acolyte

Joined: 23 Oct 2008
Posts: 52

That seems to be a reasonable way to do it. I was also thinking about looking for non-numeric characters like '/' or ':' and keying off of that.

Fortunately, we have a configuration file we read in and I can key off that value as it'll either read MQMD (in which case it's a timestamp) or it'll have an integer and we're checking for -1 (no expiry) and then treating any other value as an integer.

Also, I read a little bit more about FIELDTYPE in the ESQL PDF, and clearly it's not what I wanted even though it looked like in other posts that it would work. Kinda surprised that it seems ESQL has no function that'll let you check a variable's data type. I hope I'm wrong about that.

Thanks!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Oct 02, 2009 9:46 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Found an interesting snippet for fieldtype:
Quote:
You can also use this function to determine whether a field in a message exists. To do this, use the form:

FIELDTYPE(SomeFieldReference) IS NULL

If the field exists, an integer value is returned to the function that indicates the field type (for example, string). When this is compared to NULL, the result is FALSE. If the field does not exist, NULL is returned and therefore the result is TRUE. For example:

IF FIELDTYPE(InputRoot.XMLNS.Message1.Name)
IS NULL THEN
// Name field does not exist, take error
action....
... more ESQL ...
ELSE
// Name field does exist, continue....
... more ESQL ...
END IF



But I guess what you are really after is something like
Fieldtype(fieldvalue(ref))... Which will be string or CHARACTER if you did not use a message set for parsing?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Fri Oct 02, 2009 11:20 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Quote:

Fieldtype(fieldvalue(ref))... Which will be string or CHARACTER if you did not use a message set for parsing?


That is ok for the message body but the field in question is in the MQMD which is outside the scope of message set parsing
But hmmmm.
You could develop a message set to parse the MQMD but I'm not sure how you could handle the MQMD.Expiry field as it has two distinct formats (numeric or timestamp) inside broker.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
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 » How do I check the data type of a variable?
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.