Re: Removing a decimal from a number
Date: Fri, 19 Feb 1999 16:17:00 GMT
Message-ID: <7ak2pj$qk0$1_at_nnrp1.dejanews.com>
There might be an easier way, but you can always determine how many digits are after the decimal point (N) for each number and multiply the number by 10^N. Alternatively, you could use substr() and instr() in the STANDARD package to effectively remove the decimal point. The code will look something like this:
declare
decpos number;
fpart varchar2(10); lpart varchar2(10); cnum varchar2(21); nnum number;
newcnum varchar2(20);
newnnum number;
begin
nnum := 266.577;
cnum := standard.to_char(nnum); decpos := standard.instr(cnum,'.',1,1); fpart := standard.substr(cnum,1,decpos-1); lpart := standard.substr(cnum,decpos+1);newcnum := fpart || lpart;
newnnum := standard.to_number(newcnum); dbms_output.put_line(newnnum);
end;
Cary
In article <7ahfek$i0t$1_at_nnrp1.dejanews.com>,
david.skergan_at_cplc.com wrote:
> In a stored procedure, I am trying to read decimal values from a table and
> export them to a flat file WITHOUT their decimal point.
>
> For example:
>
> Value: 3.14159 Desired result: 314159
> Value: 200.32 Desired result: 20032
>
> What is the best way to do this?
>
> Thanks...
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Feb 19 1999 - 17:17:00 CET