?
Solved

Convert packed decimal to integer in DB2

Posted on 2011-02-17
4
Medium Priority
?
5,066 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
  • 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 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