Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: HELP! PL/SQL-LEADING ZERO
Format element
FM Returns a value with no leading or trailing blanks.
Another solution is to use the format mask 'FM0999' (leading zeros),
e.g.
insert into test (runno) values (to_char(i, 'FM0999'))
In article <8u39gu$s6f$1_at_news1.xs4all.nl>,
"Gerard Pex" <gpex_at_xs4all.nl> wrote:
> Another solution is to use the format mask '0999' (leading zeros),
>
> e.g.
>
> insert into test (runno) values (to_char(i, '0999'))
>
> But the column in table test must be of the varchar2 type.
>
> "Eric Givler" <egivler_at_flash.net> wrote in message
> news:nk3N5.5668$pq3.426243_at_news.flash.net...
> > make runno varchar2(4)
> > then insert into test (runno) values ( lpad(i,4,'0') )
> >
> > "Ho" <kowho_at_singnet.com.sg> wrote in message
> > news:8u266p$bo2$1_at_coco.singnet.com.sg...
> > > I need to create a table with 1000 records. I issue the INSERT
command
> > > within a loop.
> > >
> > > INSERT INTO TEST (RUNNO) VALUES(I)
> > >
> > > After running the SQL, the records are:
> > >
> > > 1
> > > 2
> > > 3.....
> > >
> > > What I want is :
> > >
> > > 0001
> > > 0002
> > > .
> > > .
> > > .
> > > 0999
> > > 1000
> > >
> > > How to achieve this ?
> > >
> > > Many thanks for your help in advance.
> > >
> > >
> > >
> >
> >
>
>
Stax
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Mon Nov 06 2000 - 05:00:36 CST