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: 10231
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
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm


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