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 » Strange behavior while casting an empty string to a nunmeric

Post new topic  Reply to topic
 Strange behavior while casting an empty string to a nunmeric « View previous topic :: View next topic » 
Author Message
Philipp
PostPosted: Fri Apr 11, 2014 3:48 am    Post subject: Strange behavior while casting an empty string to a nunmeric Reply with quote

Newbie

Joined: 11 Apr 2014
Posts: 2

Hello,

I am currently running a Broker 8.0.0.3 installation on RedHat 5.9 and experienced some unexpected behavior during developing:

Whilst casting an empty string to a numeric value such as INTEGER or DECIMAL, the return value is 0.

I would expect to see a cast exception here.

Is this behavior intended by IBM and if so, why?

What is your suggestion to handle these kind of casts properly if an exception is required? Check explicitly for empty strings?

Example:

DECLARE variable1 INTEGER CAST(‘’ AS INTEGER);

Variable1 has value 0, whereas we would expect to see an cast exception.


Any advice would be much appreciated.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Apr 11, 2014 4:15 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Variable1 has value 0, whereas we would expect to see an cast exception
The ESQL documentation does not state that an empty string will cause an exception ( unless I am reading it wrongly ).
Quote:
What is your suggestion to handle these kind of casts properly if an exception is required? Check explicitly for empty strings?
Apply validation in the schema that the parser is using. Then the illegal value will never reach the message flow. If the string comes from XML or DFDL, then the check can be applied using a facet value in the xsd. Make sure that you set 'Validation' to 'Content and Value' if you decide to use this solution.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
Philipp
PostPosted: Fri Apr 11, 2014 4:40 am    Post subject: Reply with quote

Newbie

Joined: 11 Apr 2014
Posts: 2

Hi kimbert, thanks a lot for your quick reply. I will give it a try.
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 » Strange behavior while casting an empty string to a nunmeric
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.