• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3585
  • Last Modified:

NUMERIC & DECIMAL data types

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.
0
k_murli_krishna
Asked:
k_murli_krishna
1 Solution
 
Kent OlsenData Warehouse Architect / DBACommented:
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:

  http://www.simotime.com/datazd01.htm
  http://www.simotime.com/datapk01.htm

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,
Kent
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now