|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Cast for Decimal Amount |
« View previous topic :: View next topic » |
Author |
Message
|
18tillidie |
Posted: Thu Jul 16, 2020 7:01 am Post subject: Cast for Decimal Amount |
|
|
Newbie
Joined: 04 May 2020 Posts: 9
|
Hello Folks,
I am new to esql and I request help with the below line of code -
SET inAmount = ROUND((CAST(SUBSTRING(ref.body1 FROM 31 FOR 10) AS DECIMAL)/100), 2);
The SUBSTRING is coming as 2555 and it needs to get converted to 25.55. The current code converts it to 26.
inAmount will also contain decimal vaule an it is not sending it. I tried a couple of castings but did not work.
In the stored proc to the external oracle DB it is define as NUMBER:
CREATE PROCEDURE AddValue(IN inAmount INTEGER)LANGUAGE DATABASE
EXTERNAL NAME "TEST"; |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jul 16, 2020 10:22 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
How is inAmount defined in ESQL?
Why do you want it as a decimal when the stored procedure has inAmount (which I'm assuming you're passing) as a integer?
For diagnostic & training purposes, break down the ESQL statement. Take the substring, cast it and so forth all in separate statements. See where it goes wrong. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
18tillidie |
Posted: Thu Jul 16, 2020 10:34 am Post subject: |
|
|
Newbie
Joined: 04 May 2020 Posts: 9
|
Thanks Vitor, issue resolved, changed the data type to Decimal all through, in the code and in the procedure and it worked. Oracle datatype NUMBER takes both integer and decimal values.
SET inAmount = CAST(SUBSTRING(reftoBody.body_elem1 FROM 31 FOR 10)AS DECIMAL)/100; |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jul 16, 2020 12:01 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
18tillidie wrote: |
Oracle datatype NUMBER takes both integer and decimal values. |
18tillidie wrote: |
CREATE PROCEDURE AddValue(IN inAmount INTEGER)LANGUAGE DATABASE
EXTERNAL NAME "TEST";
|
I don't see where you're using NUMBER.
18tillidie wrote: |
SET inAmount = CAST(SUBSTRING(reftoBody.body_elem1 FROM 31 FOR 10)AS DECIMAL)/100; |
I also don't see how this varies from your previous ESQL. But as long as you have it working. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
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
|
|
|
|