473,473 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Decimal Formating issue

vp
Hi all,

I have a field AMOUNT(Decimal 13,2) and when I check the length its
coming as 7.

AMOUNT LENGTH
15.00 7
118.00 7
0.00 7
10.00 7

I need to format theAMOUNT field so that when I do a length of it I
should get 14(this includes a decimal)
Example
AMOUNT LENGTH
12345678911.58 14

if the amount is 15.00 I have to LPAD appropriate spaces so that when i
do lengthg of the amount it should come like ' 15.00' ...
I tried doing
RIGHT(' .00'||RTRIM(char(dec(AMOUNT,13,2))),14)

but I am getting like 00000000015.00 and I have 5 other amount fields
and when I use it in SQL getting SQL1585N A system temporary table
space with sufficient page
size does not exist. SQLSTATE=54048

please advice me.....

Feb 9 '06 #1
3 7136
The length of a Decimal 13,2 column is seven (7) bytes, exactly what the
length function reports. Standard formatting by the clp places the data
in a 15 print position wide field with leading blanks. the two extra
bytes in the output field are to provide space for the decimal point and
a possible sign.

Decimal data is stored placing two digits en each byte, with one nibble
(half a byte) reserved for the sign. 13+1 = 14; 14/2 = 7. The two (2) in
the column definition describes the placement of the decimal point.

Multiplying the length by two for decimal columns will not give you the
defined length either. A column defined as 14,2 takes up the same
physical space as one defined as 15,2.

The catalog tables contain information about column definitions and can
be used to retrieve the size of the decimal column. When you set up a
field to display the data, don't forget to provide space for a sign and
the decimal point.

Phil Sherman
vp wrote:
Hi all,

I have a field AMOUNT(Decimal 13,2) and when I check the length its
coming as 7.

AMOUNT LENGTH
15.00 7
118.00 7
0.00 7
10.00 7

I need to format theAMOUNT field so that when I do a length of it I
should get 14(this includes a decimal)
Example
AMOUNT LENGTH
12345678911.58 14

if the amount is 15.00 I have to LPAD appropriate spaces so that when i
do lengthg of the amount it should come like ' 15.00' ...
I tried doing
RIGHT(' .00'||RTRIM(char(dec(AMOUNT,13,2))),14)

but I am getting like 00000000015.00 and I have 5 other amount fields
and when I use it in SQL getting SQL1585N A system temporary table
space with sufficient page
size does not exist. SQLSTATE=54048

please advice me.....

Feb 9 '06 #2
1) There may be more simple way. But, anyway this will satisfy your
requirement.
SUBSTR(' '||TRANSLATE(LTRIM(TRANSLATE(CHAR(AMOUNT),'
','0')),'0',' '),LENGTH(LTRIM(TRANSLATE(CHAR(AMOUNT),' ','0')))-3,14)

2) The reason of SQL1585N must be that function RIGHT is a DB2 supplied
UDF (schema is SYSFUN) and the attribute of returned data is
VARCHAR(4000).
So, if you use 5 such expressions, one row will exceeds at least 20,000
byte. This meas that 32K page temporary table is required.
One way to reduce the size is using SUBSTR.
Like this:
SUBSTR(RIGHT(.........), 1, 14)

Feb 10 '06 #3
1) There may be more simple way.
But, anyway this will meet your requirement.
SUBSTR(' '||TRANSLATE(LTRIM(TRANSLATE(CHAR(AMOUNT),'
','0')),'0',' '),LENGTH(LTRIM(TRANSLATE(CHAR(AMOUNT),' ','0')))-3,14)

2) The reason of SQL1585N is that function RIGHT is a DB2 supplied
UDF(schema is SYSFUN). So, attribute of returned value is
VARCHAR(4000). If you use 5 such expressions, size of one row exceeds
20,000.

Feb 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
6
by: Newbee Adam | last post by:
I have been reading in help how I need to use decimal becuase currency does not exist like I used in vb6. I had a difficult time on google and msdn finding how or if I can take the value of text...
2
by: Nadav | last post by:
Hi, How can I use C# to print a number in hexadecimal e.g. printf(" %x "); or print 15 ( decimal ) as 'F' (hexa) Can a number be printed as binary as-well? Thanks in advance, Nadav.
6
by: Bill | last post by:
Hi I am having trouble trying to format a number string to two decimal places if the number ends in a 0 It formats fine otherwise. For example if PrincRepay is 78.20 it will display it as 78.2...
4
by: jaYPee | last post by:
I have a report created in crystal report. My problem is on how can I remove the decimal point without converting the value. say for example if I have this data: Unit 2 1.5 2 3
1
by: Hiranmoy | last post by:
I have table with some fields in which a field contains values like 42.32, 64.68, 80.30, 70.95 etc. Is it possible to design the number format be always Rounded Up like 43, 65, 81, 71 etc.? I have...
6
by: Terry Reedy | last post by:
Gerhard Häring wrote: The new fractions module acts differently, which is to say, as most would want. True Traceback (most recent call last): File "<pyshell#20>", line 1, in <module> F(1.0)...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.