I was trying to pad left spaces to a number, so that in my view they would all be formatted (in the view they cannot be formatted).
When I test the following function:
LENGTH (TO_CHAR(a.variacion*100,'999990.99'))
oh coincidence all numbers measure 11.
However, as seen in the following list, this is not real. So, where does Oracle get that 11???
11 -59.00
11 1.00
11 -76.00
11 -5.00
11 -24.00
11 37.00
11 -47.00
11 -14.00
11 -21.00
11 -50.00
11 0.00
11 6032.00
11 -64.00
11 -6.00
11 -28.00
11 -59.00
As a clarification, if I change the mask to something else, for example to TO_CHAR(a.variacion*100,'990.99')
, the following is output:
8 -59.00
8 1.00
8 -76.00
8 -5.00
8 -24.00
8 37.00
8 -47.00
8 -14.00
8 -21.00
8 -50.00
8 0.00
8 #######
8 -64.00
8 -6.00
8 -28.00
8 -59.00
In other words, the problem is the mask... but what does that have to do with it???
This is the expected behavior for the Format Models used in the function
TO_CHAR
.The will
9
replace them with spaces (' '
) if they do not take any value and will also add a space before them, as you can see in this query:Result:
If you look closely, your plot corresponds to the result except that it
TO_CHAR
has added an extra space (marked in the example with the character_
):To eliminate it you must use the so-called Fill Mode Modifier (
FM
) as the documentation indicates :However, and as I have explained to you before, if you want to keep the decimal part, I advise you to change the decimal plot from 99 to 00:
I give you the complete example:
All the best