Solved

Convert packed decimal to integer in DB2

Posted on 2011-02-17
4
4,102 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
Comment Utility
How about

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

wmp
0
 
LVL 8

Author Comment

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

Accepted Solution

by:
woolmilkporc earned 500 total points
Comment Utility
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
Comment Utility
Thank you!
It worked like a magic.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now