All function parameters become NULL if one is?

Started by Joel Burtonover 25 years ago2 messagesgeneral
Jump to latest
#1Joel Burton
jburton@scw.org

I have a function that takes two text parameters. If both of these
are non-null, everything works fine. However, if one of these two
parameters is null and one is not, the function receives both as null.

CREATE FUNCTION F(TEXT,TEXT) RETURNS TEXT AS '
BEGIN
RETURN $2;
END;
' LANGUAGE 'plpgsql';

SELECT F(null,'Hello');

returns null.

Is this intentional? Is there a way around this?
--
Joel Burton, Director of Information Systems -*- jburton@scw.org
Support Center of Washington (www.scw.org)

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Joel Burton (#1)
Re: All function parameters become NULL if one is?

Joel Burton writes:

I have a function that takes two text parameters. If both of these
are non-null, everything works fine. However, if one of these two
parameters is null and one is not, the function receives both as null.

Worse, no matter what the function does, the return value is also null.

Is this intentional? Is there a way around this?

Wait for 7.1.

--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/