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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Format Numbers Oracle

Re: Format Numbers Oracle

From: Jim Kennedy <jim>
Date: Tue, 14 Mar 2006 22:58:16 -0800
Message-ID: <48idna0w4sUcJ4rZnZ2dnUVZ_sidnZ2d@comcast.com>

"Joe" <shiljo.ap_at_gmail.com> wrote in message news:1142404768.388624.49950_at_i39g2000cwa.googlegroups.com...
> Hi
>
> I got a table named books with its field name Accno (access number) and
> author (Name of the author).
>
> i created a sequence with the following syntax
>
> create sequence seqbook increment by 00000001 start with 000000001
> maxvalue 99999999 minvalue 00000001 nocycle cache 4;
>
> and Oracle created the sequence.
>
> after that i inserted it into the table
>
> insert into books values(seqbook.nextval, 'Joseph');
>
> and oracle inserted the values into the table books
>
> and while querying "select * from books;"
>
> Accno Author
> 1 Joseph
>
>
> I wanted the access number to be stored in as 00000001 insted of 1.
> what should i do in order to get the output like 00000001.
>
> Thanks in advance.
> Thanks & regards
> Shiljo
>

You are storing the sequence as a number. (Which is the correct thing to do.) You are asking for it to be displayed in a particular string format. To do that you would do
select to_char(my_column,'00000000') from books;

see the docs the SQL Reference guide, to_char and formats. (eg otn.oracle.com documentation)
Jim Received on Wed Mar 15 2006 - 00:58:16 CST

Original text of this message

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