Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 8755E2E00F7 for ; Fri, 22 Feb 2008 18:01:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 50905-03 for ; Fri, 22 Feb 2008 18:01:45 -0400 (AST) X-Greylist: delayed 02:35:49.485619 by SQLgrey-1.7.5 Received: from que03.charter.net (que03.charter.net [209.225.8.191]) by postgresql.org (Postfix) with ESMTP id BA44D2E00F9 for ; Fri, 22 Feb 2008 18:01:49 -0400 (AST) Received: from aarprv06.charter.net ([10.20.200.76]) by mta12.charter.net (InterMail vM.7.08.03.00 201-2186-126-20070710) with ESMTP id <20080222163102.HSPI22287.mta12.charter.net@aarprv06.charter.net> for ; Fri, 22 Feb 2008 11:31:02 -0500 Received: from [192.168.1.215] (really [68.186.33.18]) by aarprv06.charter.net with ESMTP id <20080222163102.IPZE14098.aarprv06.charter.net@[192.168.1.215]> for ; Fri, 22 Feb 2008 11:31:02 -0500 From: johnf To: pgsql-sql@postgresql.org Subject: Re: postgresql function not accepting null values inselect statement Date: Fri, 22 Feb 2008 08:30:56 -0800 User-Agent: KMail/1.9.6 (enterprise 20070904.708012) References: <001501c8752d$391c8e50$ab55aaf0$@com> <001a01c87534$84eea280$8ecbe780$@com> <47BEA582.A3DD.0030.0@indicator.be> In-Reply-To: <47BEA582.A3DD.0030.0@indicator.be> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802220830.56917.jfabiani@yolo.com> X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/167 X-Sequence-Number: 30258 On Friday 22 February 2008 01:35:47 am Bart Degryse wrote: > Can you try this... > > CREATE OR REPLACE FUNCTION getfunctionaries(p_statecd integer) > RETURNS SETOF t_functionaries AS > $BODY$ > DECLARE > rec t_functionaries%ROWTYPE; > BEGIN > FOR rec IN ( > SELECT f.functionaryid, f.category, f.description > FROM functionaries f > WHERE f.statecd IS NOT DISTINCT FROM p_statecd) > LOOP > return next rec; > END LOOP; > return; > END; > $BODY$ > LANGUAGE 'plpgsql' VOLATILE; > a newbie question. Could you explain why yours works? I don't understand how it works if p_statecd = NULL -- John Fabiani