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

From: Jared Still <jkstill_at_gmail.com>
Date: Mon, 17 Oct 2011 09:49:50 -0700
Message-ID: <CAORjz=MqgXiko5mtKW-Lcpc9tzW+AeMVQjwz0U-KaRhk96+nRQ_at_mail.gmail.com>



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_at_gmail.com> 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_at_yahoo.com>
>
> > SQL> column result format 999990.90
> > SQL>
> > SQL> select 1/2 result from dual;
> > RESULT
> > ----------
> > 0.50
> > SQL>
> >
> > David Fitzjarrell
> >
> >
> > *From:* amonte <ax.mount_at_gmail.com>
> > *To:* Oracle-L Group <oracle-l_at_freelists.org>
> > *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
> >
> >
> > --
> > http://www.freelists.org/webpage/oracle-l
> >
> >
> >
> >
> >
>
>
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Oct 17 2011 - 11:49:50 CDT

Original text of this message