Author |
Message
|
vijayakumar |
Posted: Thu Aug 11, 2011 12:28 pm Post subject: Truncate function - esql |
|
|
Centurion
Joined: 01 Aug 2010 Posts: 101
|
I used truncate function in my esql.
TRUNCATE(InputRoot.XML.CodeNumber, 2)
My input Code Number should be like 14998.27654
I want to convert it in to 14998.27
I got the error as
Illegal 1st argument (value ''14998.27654'') to function TRUNCATE; numeric value required; value of 2nd argument was '2'.
Then I changed the code to
TRUNCATE(cast(InputRoot.XML.CodeNumber as INTEGER), 2),
Now I am getting the error as
Error casting character string '14998.27654' to an integer .
Kindly advise how to use this. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 11, 2011 12:33 pm Post subject: Re: Truncate function - esql |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vijayakumar wrote: |
Error casting character string '14998.27654' to an integer .
Kindly advise how to use this. |
Learn the difference between an integer and a decimal?
Then you might realise why WMB is telling you that '14998.27654' can't be converted to that data type.
This is a problem with your mathmatics, not your ESQL.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
vijayakumar |
Posted: Thu Aug 11, 2011 12:46 pm Post subject: |
|
|
Centurion
Joined: 01 Aug 2010 Posts: 101
|
TRUNCATE(InputRoot.XML.CodeNumber, 2)
Illegal 1st argument (value ''14998.27654'') to function TRUNCATE; numeric value required; value of 2nd argument was '2'.
From which data type to which one , I have to cast to make the function work |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 11, 2011 12:50 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vijayakumar wrote: |
From which data type to which one , I have to cast to make the function work |
Did you even read my previous post?
Or did you just glance at it, not see any new ESQL and decide to ask the question again?
Seriously.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 11, 2011 12:57 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Here's another clue, as you appeared to have missed the school day when they talked about fractions:
What are you assigning the result of the TRUNCATE function to, when you finally get it working? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mapa |
Posted: Thu Aug 11, 2011 2:22 pm Post subject: |
|
|
 Master
Joined: 09 Aug 2001 Posts: 257 Location: Malmö, Sweden
|
Perhaps also take a look into the other message domains for xml.
XML is deprecated, use XMLNSC instead (or XMLNS if you must).
And if you look in the Information Center for the WMB there is actually a lot of ESQL code examples of casting between different datatypes. _________________ Brgds, Magnus Palmér
Enfo Zystems |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 11, 2011 4:57 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mapa wrote: |
XML is deprecated, use XMLNSC instead (or XMLNS if you must). |
But given the nature of the problem I feared this would just confuse the OP. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|