Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Number formatting question
Ashish wrote:
> Hi,
>
> Sorry for asking such a dumb question.
> I have an alphanumeric key, the last 2 digits of which should increment
> every time a new record is saved. For this, I extract the last 2 digits
> from the key (using substr) and increment it (add 1 to it). But when i
> do a to_char() of this new number, it introduces a blank space.
>
> For example: My key is in this format : TR05SEP200601. Here TR is item
> code(say), 05SEP2006 is the system date and 01 is the serial number. If
> i save another item of type TR on 05-SEP-2006, the number should be
> TR05SEP200602.
> To achieve this, i extract the last 2 digits of the key and add 1 to
> it. But doing this converts it to a number and instead of displaying it
> as '02' it displays it as '2'. If i try to use a to_char() function, it
> includes an additional space which makes it like ' 02'.
>
> Any help in this would be greatly appreciated.
>
> Ashish
select '#'||to_char(2, 'fm09') from dual
As documented in the sql reference manual.
-- Sybrand Bakker Senior Oracle DBAReceived on Wed Sep 06 2006 - 04:20:48 CDT
![]() |
![]() |