Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D9FE62E015C for ; Fri, 22 Feb 2008 05:24:29 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 80632-06 for ; Fri, 22 Feb 2008 05:24:11 -0400 (AST) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.227]) by postgresql.org (Postfix) with ESMTP id 52FDE2E00F1 for ; Fri, 22 Feb 2008 05:24:11 -0400 (AST) Received: by wx-out-0506.google.com with SMTP id r21so312589wxc.28 for ; Fri, 22 Feb 2008 01:24:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:references:in-reply-to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:thread-index:content-language; bh=dLjHENIYUe8O4ehkJ/WhFBC2FAMcvbfMsWPC2OhpkzE=; b=g274quhwUp71Ms24uoHyTJlY3ijCumbizJ7hHRTBuBVaFc2sD44NYhUOgFWVFLsKz0iSiKJ8g1YRUYdXXGDsYYGgJ7S3d8SwKpXBT1+cxNYN7hGua8LJV0KtE9XttY8ppLupWRShWTP8kGTKFStp+cVPOulFjNyh9Qy39JHiba8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:references:in-reply-to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:thread-index:content-language; b=sQDfUgJGgNjfj9PmejrZFPWEI0X09de2NRBRejRp9t6PSDawKExpMjNfRr6InOI3RAOH8ArOdzbWj594woAj/hYehJBo7/hQeYEes6hls5dxK9SS7yTtuoUzXCcpx1u2LEnX54lU55vROJlDBUKUenmu3PGq9ijlEN8S/Ptbr7Y= Received: by 10.141.205.10 with SMTP id h10mr7456662rvq.138.1203672249458; Fri, 22 Feb 2008 01:24:09 -0800 (PST) Received: from BITDLLT03 ( [122.162.21.57]) by mx.google.com with ESMTPS id f34sm2262062rvb.3.2008.02.22.01.24.06 (version=SSLv3 cipher=RC4-MD5); Fri, 22 Feb 2008 01:24:08 -0800 (PST) From: "Jyoti Seth" To: "'Richard Huxton'" Cc: References: <001501c8752d$391c8e50$ab55aaf0$@com> <47BE9058.9030909@archonet.com> In-Reply-To: <47BE9058.9030909@archonet.com> Subject: Re: postgresql function not accepting null values in select statement Date: Fri, 22 Feb 2008 14:52:55 +0530 Message-ID: <001a01c87534$84eea280$8ecbe780$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ach1MhKL0i37PpGHRTWySgRUF20FmAAASc6Q Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/160 X-Sequence-Number: 30251 Hi, I have a the following procedure 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=p_statecd LOOP return next rec; END LOOP; return; end; $BODY$ LANGUAGE 'plpgsql' VOLATILE; In the functionaries table statecd is a null field. When I pass some integer value to the above procedure it works correctly but if I pass null value in p_statecd it doesn't show anything whereas it has values and if I write the select statement separately it gives values Thanks, Jyoti -----Original Message----- From: Richard Huxton [mailto:dev@archonet.com] Sent: Friday, February 22, 2008 2:35 PM To: Jyoti Seth Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] postgresql function not accepting null values in select statement Jyoti Seth wrote: > > If I pass null value as the parameter of postgresql function, which is used > in the where clause of select statement is not functioning properly. Either: 1. You're talking about frooble(), in which case it's supposed to do that. or 2. You'll need to tell us what function it is, how you're using it and what you think should happen. My guess is that you're getting a null as the result and that's not doing what you'd expect in your where clause. -- Richard Huxton Archonet Ltd