NUMERIC & DECIMAL data types

Posted on 2007-07-28
Last Modified: 2008-02-01
1) We have DB2 9 on Red Hat LInux 9.
2) We received a DB2 9 on AS/400 schema DDL
3) At some places NUMERIC data type is used which is not there in our UDB.
4) DECIMAL is also used which is available as data type in our UDB
5) The only difference between the two is one is packed decimal and the other is zoned deciaml.
6) What is this packed and zoned. Can you explain me in simple language.
7) Can I substitute DECIMAL for NUMERIC & if so will Precision and scale remain same.
Question by:k_murli_krishna
    1 Comment
    LVL 45

    Accepted Solution

    Hi k,

    Zoned and Packed decimal are throwbacks to a day when computers supported base 10 arithmetic, mostly for COBOL applications.  The exact details are probably beyond a simple explanation, but if you want to know how they work, here are a couple of links that describe the formats:

    You can use the DECIMAL type in UDB.  To the SQL user, it will behave the same as the packed data types.  Even the syntax is similar.

    If your application deals with money, or other fixed point arithmetic, stick with DECIMAL.  Otherwise, think seriously about FLOAT or DOUBLE.  They don't allow you to specify precision and scale, but are usually large enough for most applications.

    Money is different.  When dealing with fractions of dollars, the U.S. (as well as most other countries) have laws that dictate the precision and scale.  Use DECIMAL for money.

    Good Luck,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    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…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    761 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

    7 Experts available now in Live!

    Get 1:1 Help Now