IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Not able to fetch DB2 DECIMAL data correctly in REXX.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Oct 08, 2009 12:07 pm
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Oct 08, 2009 1:35 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Oct 08, 2009 2:04 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 2
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top