|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Strange behavior while casting an empty string to a nunmeric |
« View previous topic :: View next topic » |
Author |
Message
|
Philipp |
Posted: Fri Apr 11, 2014 3:48 am Post subject: Strange behavior while casting an empty string to a nunmeric |
|
|
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 |
|
 |
kimbert |
Posted: Fri Apr 11, 2014 4:15 am Post subject: |
|
|
 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 |
|
 |
Philipp |
Posted: Fri Apr 11, 2014 4:40 am Post subject: |
|
|
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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|