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 determine scalar type of field in ESQL

Post new topic  Reply to topic
 How to determine scalar type of field in ESQL « View previous topic :: View next topic » 
Author Message
Jenum
PostPosted: Thu Sep 03, 2015 9:07 am    Post subject: How to determine scalar type of field in ESQL Reply with quote

Novice

Joined: 13 Nov 2012
Posts: 24

Hi all!
I have problem: i need check, whether field is string or number (in the incoming JSON-message). Is it possible?
I have only one idea: use CAST(... AS DOUBLE) on this field and catch exception - if it is, then field is string. But it no very good solution...
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Sep 03, 2015 10:03 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.

Could it be a string that contains numbers and a '.'?

To test if a field contains only numeric digits and a '.' then you can use the solution described here
http://mqseries.net/phpBB/viewtopic.php?t=51183&sid=1b332f7d593c914f4274bf7b64adf890
_________________
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
timber
PostPosted: Thu Sep 03, 2015 10:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1292

Quote:
i need check, whether field is string or number (in the incoming JSON-message).
Is this for validation, or some other purpose?
Back to top
View user's profile Send private message
Jenum
PostPosted: Thu Sep 03, 2015 11:03 pm    Post subject: Reply with quote

Novice

Joined: 13 Nov 2012
Posts: 24

timber, other purpose: processing of the field depends on its value
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Sep 04, 2015 12:46 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.

Jenum wrote:
timber, other purpose: processing of the field depends on its value


So you can check to see if the field contains the right sort of characters as I described above. Then if that passes you can cast the string to a field of the right type knowing that it will not cause an exception.
_________________
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
mqjeff
PostPosted: Fri Sep 04, 2015 4:41 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Jenum wrote:
timber, other purpose: processing of the field depends on its value

That doesn't seem like a good design for the data structure.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
timber
PostPosted: Fri Sep 04, 2015 7:29 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1292

Quote:
I have only one idea: use CAST(... AS DOUBLE) on this field and catch exception - if it is, then field is string. But it no very good solution...
Sounds like a reasonable solution to me. What's wrong with it?
[/quote]
Back to top
View user's profile Send private message
mgk
PostPosted: Sat Sep 05, 2015 5:57 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Use the DEFAULT clause on the CAST - is supresses the exception and sets the result to the value of the DEFAULT specified.

Kind regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
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 to determine scalar type of field in ESQL
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.