Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Number to Char conversion

Re: Number to Char conversion

From: Jeff Kalchik <jeff_kalchik_at_spam-me-not.mw.3com.com>
Date: Tue, 09 Feb 1999 18:23:54 GMT
Message-ID: <36c07c9b.2077077@news.usr.com>


On 9 Feb 1999 05:02:11 GMT, gennick_at_worldnet.att.net (Jonathan Gennick) wrote:

>On 7 Feb 1999 18:05:24 +0100, mattias.meyer_at_t-online.de
>(mme) wrote:
>
>>When I do the following in PL/SQL:
>>
>><string> := TO_CHAR(<number>, '00');
><snip>
>>Why do I always get a errormessage saying the the conversion canīt be done?
>>When I declare the <string> as a CHAR(3) it works... but I get a
>>space/blank
>>as first position of the string. How come?
>
>Oracle is leaving one space for a leading sign. Convert a
>negative number, and you will see a "-" character in that
>position. Positive numbers get a space. This is by design.
>As you have already figured out, you must use LTRIM to
>eliminate that leading space.
>
>regards,
>
>Jonathan
>----------------------------------------------
>Jonathan Gennick -- Oracle DBA, Author, Editor
>jonathan_at_gennick.com
>http://gennick.com
>Brighten the corner where you are.
>
>>
>>I then use
>>LTRIM(<string>, ' ');
>>but I wanna know why it works the way it does????
>>
>>Regards

Alternatively,

<string> := to_char(<number>, 'FM00');

will format without the leading space.

Straight from Chap. 3 of Oracle PL/SQL Programming. The FM format modifier is listed as returning a value with no leading or trailing blanks.



Jeff Kalchik
Views expressed are my own, not my employers. Received on Tue Feb 09 1999 - 12:23:54 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US