Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Not able to fetch DB2 DECIMAL data correctly in REXX.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Gaurav Chauhan

New User


Joined: 29 Oct 2007
Posts: 17
Location: Noida

PostPosted: Thu Oct 08, 2009 11:52 am    Post subject: Not able to fetch DB2 DECIMAL data correctly in REXX.
Reply with quote

I am using a SQL query in REXX to fetch data froma DB2 table. DB2 column has been defined as DECIMAL(12,2).

SQLQUERY = "SELECT COLUMNA AS REXXVAR ",
"FROM TABLEA ",
"WITH UR ; "

ADDRESS DB2 "SQL" SQLQUERY

Here COLUMNA has been defined as DECIMA(12,2) and REXXVAR is the variable where I am fetching this value.
But I am not getting data in correct format.
eg:- If COLUMNA has value 45.67, then it is being fetched as 4567 without decimal place.

Please assist.
Thanks.
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Oct 08, 2009 12:07 pm    Post subject:
Reply with quote

Then you need to divide by 100 to get the required result.
Back to top
View user's profile Send private message
Gaurav Chauhan

New User


Joined: 29 Oct 2007
Posts: 17
Location: Noida

PostPosted: Thu Oct 08, 2009 1:16 pm    Post subject:
Reply with quote

expat wrote:
Then you need to divide by 100 to get the required result.

But tool that I am generating would have random numbers. I can't hardcode by dividing by 100. Is there any REXX function to come to rescue ?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Oct 08, 2009 1:35 pm    Post subject:
Reply with quote

As I understand this, the format of the data has been defined as DECIMA(12,2), which I take to mean that the field is 12 bytes long, with the last two bytes being the 2 decimal places.

I guess it's like the SAS format 12.2 or COBOL PIC 9(10)V99 where the decimal point is infered rather than physical.

The format is defined to one language / database but unknown to another, as DECIMA(12,2) is unknown to REXX. You need to adapt the second language / database to interpret the data format correctly.

Obviously if I have misunderstood your request, please feel free to clarify.
Back to top
View user's profile Send private message
Gaurav Chauhan

New User


Joined: 29 Oct 2007
Posts: 17
Location: Noida

PostPosted: Thu Oct 08, 2009 2:00 pm    Post subject:
Reply with quote

expat wrote:

The format is defined to one language / database but unknown to another, as DECIMA(12,2) is unknown to REXX. You need to adapt the second language / database to interpret the data format correctly.

you are right here. But that's what I need to know here.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10257
Location: italy

PostPosted: Thu Oct 08, 2009 2:04 pm    Post subject: Reply to: Not able to fetch DB2 DECIMAL data correctly in RE
Reply with quote

that' s what we are telling You,
for what reason are You concerned about the random ******
the table definition is the decision maker here

divide by 100 full stop
or by a power of ten congruent with the number of decimal places
Back to top
View user's profile Send private message
Gaurav Chauhan

New User


Joined: 29 Oct 2007
Posts: 17
Location: Noida

PostPosted: Thu Oct 08, 2009 5:21 pm    Post subject: Reply to: Not able to fetch DB2 DECIMAL data correctly in RE
Reply with quote

Did the trick.
Didn't get it initially. Thanks
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts Running an REXX EXEC implicitly sho7hills CLIST & REXX 3 Thu Apr 20, 2017 8:14 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us