Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004

    Unanswered: Show column with integer value to decimal

    I must execute this decimal operation:
    (column1 / (1 + (column2 / 100)))

    column1 and column2 are decimal(16,2) with a few integer value exmple:

    It doesn't work..why?? ..for example:
    -- Yes
    (300.00 / (1 + (column2 / 100)))
    -- No :-(
    (300/ (1 + (column2 / 100)))
    and i return this:

    A decimal divide operation is not valid because the result would have a negative scale.

    Explanation: A specified decimal division is not valid because it will result in a negative scale.
    The formula used internally to calculate the scale of the result for decimal division is:
    Scale of result = 31 - np + ns - ds where np is the precision of the numerator, ns is the scale of the numerator, and ds is the scale of the denominator.

    User Response:
    Examine and ensure the precision and scale of all columns that may participate in a decimal division. Note that an integer or small integer value may be converted to a decimal for this calculation.

    sqlcode: -419 sqlstate: 42911

    Thank you very much.
    Last edited by petitof; 07-23-08 at 06:07.

  2. #2
    Join Date
    May 2003
    Try putting decimals in all your literals (1.0 and 100.0).
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts