pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Picard, Cyril <cyril.picard@eads-dsn.com>
To: pgsql-sql@postgresql.org
Subject: passing null parameter to plpgsq functions
Date: Tue, 3 Apr 2001 09:00:26 +0200
Message-ID: <B5CDCF382265D311BF33009027A8FE9401E6F365@pmrmsg.edsn.com> (raw)

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 '
begin
	IF ($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)






view thread (4+ messages)  latest in thread

Message-ID: <B5CDCF382265D311BF33009027A8FE9401E6F365@pmrmsg.edsn.com>
Permalink:  ../B5CDCF382265D311BF33009027A8FE9401E6F365@pmrmsg.edsn.com/
Also on:    postgresql.org/message-id/B5CDCF382265D311BF33009027A8FE9401E6F365@pmrmsg.edsn.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: cyril.picard@eads-dsn.com
  Subject: Re: passing null parameter to plpgsq functions
  In-Reply-To: <B5CDCF382265D311BF33009027A8FE9401E6F365@pmrmsg.edsn.com>
  References: <B5CDCF382265D311BF33009027A8FE9401E6F365@pmrmsg.edsn.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox