Null Value function
Posted in 1999
Topics: General Discussion
Is there a function in Informix SQL that is equivilent to the Oracle NVL function or the Sybase ISNULL function? NVL(val1, val2) returns val1 if it is not null, otherwise it returns val2... I looked through the SQL syntax book with no luck... --- Timothy Friest - Science Application International Corp (SAIC) Anchorage Alaska 907-272-7105
Tim Friest wrote:
> Is there a function in Informix SQL that is equivilent to the
> Oracle NVL function or the Sybase ISNULL function?
If you've got the right version of Informix, the function is called
NVL and behaves like the Oracle version. If you don't have the right
version, you can right a stored procedure which does the job.
Ah, he says, but what's the right version?
7.30.
> NVL(val1, val2) returns val1 if it is not null, otherwise it returns
> val2...
>
> I looked through the SQL syntax book with no luck...
That suggests you need the SPL version:
CREATE PROCEDURE nvl(v1 VARCHAR(255), v2 VARCHAR(255))
RETURNING VARCHAR(255); IF v1 IS NOT NULL THEN
RETURN v1;
ELSE
RETURN v2;
END IF;
END PROCEDURE;
This isn't quite a fully satisfactory substitute for the real
NVL because of problems with the return type in some circumstances,
but it generally works OK for most people, most of the time.
Oh, I retyped that on the fly, so it isn't syntax checked. And it
doesn't handle more than two arguments, and ...
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>
The NVL function is a new feature in IDS 7.30. Andreas Wellerding Tim Friest schrieb in Nachricht <36CCCC84.277F1184@saic.alaska.net>... >Is there a function in Informix SQL that is equivilent to the Oracle NVL >function or >the Sybase ISNULL function? > >NVL(val1, val2) returns val1 if it is not null, otherwise it returns >val2... > >I looked through the SQL syntax book with no luck... > >--- >Timothy Friest - Science Application International Corp (SAIC) >Anchorage Alaska >907-272-7105 > > >