DB2 Summing - Decimals? 
Author Message
 DB2 Summing - Decimals?

Greets, all... a bit of this was covered a few weeks back but I've run
into another interesting wrinkle.

The column is TOTAL_PRICE DECIMAL(11, 2); this gets translated into
BFLGMP-TOTAL-PRICE PIC S9(09)V99 USAGE COMP-3.  What's needed is a SELECT
SUM(TOTAL_PRICE) INTO :WS-SUMTOT... and I seem to be losing the decimals
when I define WS-SUMTOT PIC S9(9) COMP VALUE +0.

Other definitions give 'INVALID HOST VARIABLE' errors and trying to
REDEFINE the field still loses the decimals... anyone know where I might
find a way out?

Thanks much.

DD



Wed, 25 Feb 2004 02:49:02 GMT  
 DB2 Summing - Decimals?
    If I understand you correctly, WS-SUMTOT needs to be of the same data
type (packed decimal) and length as the column being summed.  You're losing
the decimal places because an integer data type (binary) has no decimals.

--

....Terry


Quote:

> Greets, all... a bit of this was covered a few weeks back but I've run
> into another interesting wrinkle.

> The column is TOTAL_PRICE DECIMAL(11, 2); this gets translated into
> BFLGMP-TOTAL-PRICE PIC S9(09)V99 USAGE COMP-3.  What's needed is a SELECT
> SUM(TOTAL_PRICE) INTO :WS-SUMTOT... and I seem to be losing the decimals
> when I define WS-SUMTOT PIC S9(9) COMP VALUE +0.

> Other definitions give 'INVALID HOST VARIABLE' errors and trying to
> REDEFINE the field still loses the decimals... anyone know where I might
> find a way out?

> Thanks much.

> DD



Wed, 25 Feb 2004 11:18:52 GMT  
 DB2 Summing - Decimals?

Quote:

>    If I understand you correctly, WS-SUMTOT needs to be of the same data
>type (packed decimal) and length as the column being summed.  You're losing
>the decimal places because an integer data type (binary) has no decimals.

I am an idiot, I am a fool, I am a chump and a dolt, I am a janitor, not a
programmer... when I was looking at the DECLARE I mistranslated DECIMAL
(11, 2) as PIC S9(11)V99 COMP-3 instead of as S9(9)V99 COMP-3; when I
tried to define WS-SUMTOT as the former I would get the INVALID HOST
VARIABLE errors.  Your suggestion caused me to re-visit this and use the
right definition.

Greatly appreciated, Mr Heinze.

DD

Quote:


>> Greets, all... a bit of this was covered a few weeks back but I've run
>> into another interesting wrinkle.

>> The column is TOTAL_PRICE DECIMAL(11, 2); this gets translated into
>> BFLGMP-TOTAL-PRICE PIC S9(09)V99 USAGE COMP-3.  What's needed is a SELECT
>> SUM(TOTAL_PRICE) INTO :WS-SUMTOT... and I seem to be losing the decimals
>> when I define WS-SUMTOT PIC S9(9) COMP VALUE +0.

>> Other definitions give 'INVALID HOST VARIABLE' errors and trying to
>> REDEFINE the field still loses the decimals... anyone know where I might
>> find a way out?

>> Thanks much.

>> DD



Fri, 27 Feb 2004 21:14:44 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Sum of two decimal, basic program.

2. VA-smalltalk: client db2 database problem with Decimal

3. #sum and #sum:

4. how get decimal.precision and decimal.scale?

5. Decimal Point: How to Write vi′s for different decimal symbols

6. Convert from binary to decimal, hex to decimal etc

7. Decimal can be Binary Too (was decimal or rational)

8. REXX/DB2 = COBOL/DB2 ???

9. Nationwide Openings for DB2/CICS Developers and DB2 DBA's

10. Nationwide Openings for DB2/CICS Developers and DB2 DBA's

11. COBOL-DB2 Program, how to get Current timestampe from DB2

12. Python-DB2 module and DB2 Connect

 

 
Powered by phpBB® Forum Software