If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Show column with integer value to decimal

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-23-08, 04:40
petitof petitof is offline
Registered User
 
Join Date: Apr 2004
Posts: 54
Show column with integer value to decimal

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

column1 and column2 are decimal(16,2) with a few integer value exmple:
22,33
283
123,13

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

"
SQL0419N
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.
Fabio

Last edited by petitof; 07-23-08 at 05:07.
Reply With Quote
  #2 (permalink)  
Old 07-23-08, 09:01
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On