Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Precision Function

Re: Precision Function

From: Spencer <spencerp_at_swbell.net>
Date: Tue, 22 May 2001 21:12:57 -0500
Message-ID: <n0FO6.114$sv6.135483@nnrp2.sbc.net>

no builtin oracle function that i know of. you could "roll your own" function, something like this:

CREATE OR REPLACE FUNCTION get_precision (an_arg IN NUMBER
)RETURN NUMBER
IS
  li PLS_INTEGER;
BEGIN
  FOR li IN 0..37 LOOP
    IF an_arg = TRUNC(an_arg,li) THEN

      EXIT;
    END IF;
  END LOOP;

  RETURN POWER(10,-li);
END get_precision;

this has not been tested, or even compiled, but it might give you some ideas. this algorithm is a bit brute force, i wouldn't be surprised if there were a simpler, more efficient way to get the result you want.

HTH "Ravi Tata" <Ravi.Tata_at_oracle.com> wrote in message news:3B0AB7DA.3EFAD4A0_at_oracle.com...
>
> Is there a SQL Function to find the precision of a number ... Ex: If the
> number is 100.00 then the precision should be 1, 100.10 then the
> precision should be .1 , if 100.19 the precision should be 0.01 ... Any
> help is appreciated ..
>
> Ravi
>
Received on Tue May 22 2001 - 21:12:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US