Thread: All function parameters become NULL if one is?

All function parameters become NULL if one is?

From
"Joel Burton"
Date:
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)

Re: All function parameters become NULL if one is?

From
Peter Eisentraut
Date:
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/