Home » Developer & Programmer » Forms » If numbers are null
If numbers are null [message #209512] Fri, 15 December 2006 05:09 Go to next message
marlon_loyolite
Messages: 66
Registered: July 2006
Member
Hi Friends,

We are migrating our forms application from 6i to 10g and we have some issues here.
The one is ,if numbers are null we have handled that as mentioned below

IF NVL(l_numb1,' ') = NVL(l_numb2,' ')
THEN
.....
ELSE
.....
END IF;

This works fine in 6i , when migrated to 10g it shows error.
But when both the values are VARCHAR2 then no problem.

So I need to handle this in the entire application.I think the only problem
is substituting space(' ') for NUMBER variables.

Do I have any other alternative for this.

Note : It should work for both VARHCAR2 and NUMBER variables.

Regards
Marlon
Re: If numbers are null [message #209520 is a reply to message #209512] Fri, 15 December 2006 05:43 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Shouldn't NULL be checked using "IS NULL"?
Re: If numbers are null [message #209783 is a reply to message #209512] Sun, 17 December 2006 20:38 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
What you have found is one of the issues about which people were complaining. Numbers are not characters or dates.

Either use
begin
   IF    (    l_numb1 IS NULL
          AND l_numb2 IS NULL)
      OR l_numb1 = l_numb2 THEN
      null;
   ELSE
      null;
   END IF;
end;
or pick a value that is not valid for this field
begin
   IF NVL (l_numb1, -1) = NVL (l_numb2, -1) THEN
      null;
   ELSE
      null;
   END IF;
end;

But whatever you do, you have to have the same datatype for both sides of the NVL.

David
Previous Topic: Problem in date data type.
Next Topic: REMOTE LOGIN & SHUTDOWN
Goto Forum:
  


Current Time: Fri Sep 20 15:28:44 CDT 2024