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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Is there any HIGH_VLAUE or LOW_VALUE for numeric comparision

Re: Is there any HIGH_VLAUE or LOW_VALUE for numeric comparision

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sun, 11 Oct 1998 12:36:50 GMT
Message-ID: <3622a56f.2204299@192.86.155.100>


A copy of this was sent to suisum_at_freenet.edmonton.ab.ca () (if that email address didn't require changing) On 10 Oct 1998 23:34:49 GMT, you wrote:

>
>Hi John:
>
>Thank you for your help. That means there is no way to streamline the
>codes.
>

you can "streamline" the code via:

If (v_number=v_compare_value) OR (v_number is NULL and v_compare_value is NULL )

then
  do somthing;
END IF; or in a less verbose fashion, if you do this lots:

create package compare
as

   function isequal( x in number, y in number ) return boolean;
   function isequal( x in date, y in date ) return boolean;
   function isequal( x in varchar2, y in varchar2 ) return boolean;
end;

create package body compare
as

function isequal( x in number, y in number ) return boolean is
begin

   return (x=y) OR (x is NULL and y is NULL ); end;
..... (copy above code for DATE and VARCHAR implementation)

end;

and then you can code:

  if compare.isequal( v_value, v_compare_value ) then

      do something;
  end if;

>Best regards,
>
>
>John P. Higgins (jh33378_at_deere.com) wrote:
>: You might try this:
>
>: if v_number is null and v_compare_value is null then
>: do both_null_something
>: elif v_number is null then
>: do v_number_is_null_something
>: elif v_compare_value is null then
>: do v_compare_value_is_null_something
>: elif v_number := v_compare_value then
>: do equal_something
>: else do not_equal_something
>
>: Several of the *_something could be the same; do whatever you need to
>: do.
>
>: suisum_at_freenet.edmonton.ab.ca wrote:
>
>: > Hi:
>: >
>: > If I want to trap the NULL numeric value, I want it compare with the
>: > HIGH_VALUE to avoid the following situation. For instance,
>: >
>: > v_number NUMBER(5) := 99999;
>: > v_compare_value NUMBER(10) := NULL
>: >
>: > If NVL(v_number, 99999) = NVL(v_compare_value, 99999) THEN
>: > do somthing;
>: > END IF;
>: >
>: > The above statement will be TRUE as they are both 99999.
>: >
>: > --
>: > Best regards,
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Sun Oct 11 1998 - 07:36:50 CDT

Original text of this message

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