Solved

Convert packed decimal to integer in DB2

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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