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 IndexWebSphere Message Broker SupportCast for Decimal Amount

Post new topicReply to topic
Cast for Decimal Amount View previous topic :: View next topic
Author Message
18tillidie
PostPosted: Thu Jul 16, 2020 7:01 am Post subject: Cast for Decimal Amount Reply with quote

Newbie

Joined: 04 May 2020
Posts: 8

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
View user's profile Send private message
Vitor
PostPosted: Thu Jul 16, 2020 10:22 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26015
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
View user's profile Send private message
18tillidie
PostPosted: Thu Jul 16, 2020 10:34 am Post subject: Reply with quote

Newbie

Joined: 04 May 2020
Posts: 8

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
View user's profile Send private message
Vitor
PostPosted: Thu Jul 16, 2020 12:01 pm Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26015
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
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportCast for Decimal Amount
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.