>
> If it is interesting to someone, we can partially emulate COALESCE
> right now as:
>
> create function coalesce(integer) returns integer as
> 'declare
> nonullo alias for $1;
> begin
> if nonullo then
> return nonullo;
> else
> return 0;
> end if;
> end;
> ' language 'plpgsql';
> CREATE
Pardon, but you still misuse the fact, that PL/pgSQL's IF
expression is implicitly casted into a boolean. That's only
possible for integer values.
Please use
IF nonullo ISNULL THEN
RETURN 0;
ELSE
RETURN nonullo;
END IF;
instead, because this would work for other types (like text,
varchar etc.) too.
Since PL functions can be overloaded (like SQL functions), it
would be possible, but currently not that performant :-(, to
create such a function for all types required.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #