toooki
asked on
Oracle string comparison question
I have two variables in the procedure code:
f1 varchar2(60);
f2 number;
I wanted to write something under IF when NOT both of f1 and f2 are not NULL:
IF ( !( (f1 = NULL) AND (f2 = NULL) ) AND (to_number(f1) != f2) ) THEN
.....//some stuff
END IF;
I get syntax error ... not sure where I am writing incorrectly..
f1 varchar2(60);
f2 number;
I wanted to write something under IF when NOT both of f1 and f2 are not NULL:
IF ( !( (f1 = NULL) AND (f2 = NULL) ) AND (to_number(f1) != f2) ) THEN
.....//some stuff
END IF;
I get syntax error ... not sure where I am writing incorrectly..
ASKER
Thank you...
But sorry I think I stated correctly...
Can I compare f1 and f2 that are of varchar2 and number respectively?
I go into the IF loop if f1 (converted to number) and f2 are different AND (if both are not null).
So cases:
f1 f2
-----------
10 5 //goes inside IF
4 //goes inside IF
//does not go inside IF
6 //goes inside IF
8 8 //does not go inside IF
Thanks!!
But sorry I think I stated correctly...
Can I compare f1 and f2 that are of varchar2 and number respectively?
I go into the IF loop if f1 (converted to number) and f2 are different AND (if both are not null).
So cases:
f1 f2
-----------
10 5 //goes inside IF
4 //goes inside IF
//does not go inside IF
6 //goes inside IF
8 8 //does not go inside IF
Thanks!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot.
IF to_number(nvl(f1,99999999) )!=nvl(f2, 99999999) THEN
....
END IF;
This worked for me perfectly..
Thanks!
IF to_number(nvl(f1,99999999)
....
END IF;
This worked for me perfectly..
Thanks!
IF f1 is not null and f2 is not null THEN
....
END IF;