Re: NVL in Informix?
Posted in 1998
>If a (char)column has null values and you concatenate(||) this column
>with another non null(char), then you will get a null value(expression).
>Oracle for example has NVL(column, "value") function
>which allows you to "say" what value you want to be returned
>if the value of the column is null. Is there any way to do this in Informix
>without writing 4gl code(just SQL statements)?
CREATE PROCEDURE NVL ( field varchar(255), vDefault varchar(255) )
RETURNING varchar(255);DEFINE FinalValue VARCHAR(255);
IF field IS NULL THEN
LET FinalValue = vDefault;
ELSE
LET FinalValue = field;
END IF;
RETURN FinalValue;
END PROCEDURE
DOCUMENT
'Same as Oracle NVL Function: The first parameter is the column that may be
null, the second is the value to set it to if it is null. The return is the
value of the column if not null, else it is the default value.'
Warren R. Zeigler
Flying J
(435) 734-3742