passing null parameter to plpgsq functions - Mailing list pgsql-sql

From Picard, Cyril
Subject passing null parameter to plpgsq functions
Date
Msg-id B5CDCF382265D311BF33009027A8FE9401E6F365@pmrmsg.edsn.com
Whole thread Raw
List pgsql-sql
Hello 
I wrote a plpgsql function with few parameters ; when I call the function,
some of the parameters can be null.
In this case, all the parameters are considered as null in the function's
body ! is it a feature ? how can I work around this ?

Example :
CREATE FUNCTION foo(text, text) RETURNS bool  AS '
beginIF ($1 IS NULL) AND ($2 IS NULL) THEN     RETURN FALSE;ELSE     RETURN TRUE;END IF;
end;
' LANGUAGE 'plpgsql';


SELECT foo(null,'bouh') => false (I expected true)
SELECT foo('schfk',null) => false (I expected true)
SELECT foo(null,null) => false (OK)
SELECT foo('schfk','bouh') => true (OK)





pgsql-sql by date:

Previous
From: "Gerald Gutierrez"
Date:
Subject: Appropriate indices to create for these queries
Next
From: "Richard Huxton"
Date:
Subject: Re: Appropriate indices to create for these queries