Re: padding zero before decimal if result is less than 1

  • From: Jared Still <jkstill@xxxxxxxxx>
  • To: ax.mount@xxxxxxxxx
  • Date: Mon, 17 Oct 2011 09:49:50 -0700

what you are asking to print is a string, not a number.
convert to string, and pad with lpad, massage with substr()

some logic is involved as you probably only want the 0 for values < 1

Jared



On Mon, Oct 17, 2011 at 9:37 AM, amonte <ax.mount@xxxxxxxxx> wrote:

> oops
> I forgot to say that this is called inside PL/SQL and invoked from .net so
> sqlplus specifica such as column xxx cannot be used
>
> for example the pl/sql is like
>
> declare
>    l_var number;
> begin
>    l_var := 1/2;
>    dbms_output.put_line(l_var);
> end;
> /
>
> the returned value is passed to .net and this writes it to an excel cell,
> since pl/sql returns .5 when this is written to excel as number it fails!
>
> 2011/10/17 David Fitzjarrell <oratune@xxxxxxxxx>
>
> > SQL> column result format 999990.90
> > SQL>
> > SQL> select 1/2 result from dual;
> >     RESULT
> > ----------
> >       0.50
> > SQL>
> >
> > David Fitzjarrell
> >
> >
> >  *From:* amonte <ax.mount@xxxxxxxxx>
> > *To:* Oracle-L Group <oracle-l@xxxxxxxxxxxxx>
> > *Sent:* Monday, October 17, 2011 9:12 AM
> >
> > *Subject:* padding zero before decimal if result is less than 1
> >
> > Hi
> > In sqlplus when we divide if the result is less than 1, for example 0.5
> we
> > see this:
> >
> > SQL> select 1 /2 from dual;
> >
> >       1/2
> > ----------
> >         .5
> >
> > Is it possible to get 0.5 without using to_char()?
> >
> > I am fine with .5 but since this has to be written to an xls excel doesnt
> > like it!
> >
> >
> > Thank you
> >
> >
> > --
> > //www.freelists.org/webpage/oracle-l
> >
> >
> >
> >
> >
>
>
> --
> //www.freelists.org/webpage/oracle-l
>
>
>


--
//www.freelists.org/webpage/oracle-l


Other related posts: