Solved

Convert packed decimal to integer in DB2

Posted on 2011-02-17
4
4,593 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

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 (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 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