Re: Removing a decimal from a number
Date: Thu, 18 Feb 1999 23:34:59 GMT
Message-ID: <7ai833$909$1_at_nnrp1.dejanews.com>
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
>
Use TRANSLATE function. If a character (dot in your case) in from set has no match in to set, it is replaced with null (another words is removed). Since from and/or to sets can not be null, we must include some other character into both sets. For example digit 0, so 0 translates into itself:
result_string := TRANSLATE(numeric_column,'0.','0');
For example:
SQL> exec dbms_output.put_line(translate(12345.67,'0.','0')) 1234567
Solomon Yakobson.
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Feb 19 1999 - 00:34:59 CET