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
> Hi all,
>
[quoted text clipped - 24 lines]
>
> please advice me.....
Tonkuma - 10 Feb 2006 02:37 GMT
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)
Tonkuma - 10 Feb 2006 03:04 GMT
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.