Solved

Convert packed decimal to integer in DB2

Posted on 2011-02-17
4
4,425 Views
Last Modified: 2012-05-11
I have a DB2 query as shown below in mainframe environment. I am running this using PGM=IKJEFT01 utility.
//SYSTSIN  DD *                                       
  DSN SYSTEM(DB2P)                                    
  RUN PROGRAM(DSNTIAUL) PLAN(DSNTIAUL) PARM('SQL') -  
     LIB('DB2P.RUNLIB.LOAD')                          
/*                                                    
//*---------------------------------------------------
//* QUERY                                             
//*---------------------------------------------------
//SYSIN    DD *                                       
  SELECT  COUNT(RULE_ID)                              
     FROM WCS.RULE_CNTRCT                             
     GROUP BY CNTRCT_CD                               
     HAVING COUNT(RULE_ID) > 1000                     
  WITH UR;                                            
//*---------------------------------------------------
//* QUERY - OUTPUT DATASET                            
//*---------------------------------------------------
//SYSREC00 DD  SYSOUT=*                               
//*                                                   

Open in new window

But the result looks like this. I am expecting a readable format of counts. Any idea, why it is so..?
:: 
:: 
:: 
:: 
:: 

:: 






:: 
:: 



:8 
:8  

Open in new window

Any idea how to generate it in readable format..?
0
Comment
Question by:jimsweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34915549
How about

SELECT  CAST(COUNT(RULE_ID) AS INT) ...

wmp
0
 
LVL 8

Author Comment

by:jimsweb
ID: 34915588
Thank you. Unfortunately, i got the same result. :(
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 34915626
Strange!

Try CHAR or VARCHAR:

SELECT  CAST(COUNT(RULE_ID) AS CHAR) ...
SELECT  CAST(COUNT(RULE_ID) AS VARCHAR(32)) ...
0
 
LVL 8

Author Closing Comment

by:jimsweb
ID: 34915783
Thank you!
It worked like a magic.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question