X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BD858D1E0BB for ; Fri, 20 Feb 2004 11:09:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 18886-10 for ; Fri, 20 Feb 2004 07:09:38 -0400 (AST) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id 7F2F6D1DFFE for ; Fri, 20 Feb 2004 07:09:35 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) id 1Au8XJ-000Pbx-0Z; Fri, 20 Feb 2004 11:09:37 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id EDC8E15983; Fri, 20 Feb 2004 11:09:35 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id E127C15911; Fri, 20 Feb 2004 11:09:33 +0000 (GMT) From: Richard Huxton To: Plant Thomas , "'pgsql-sql@postgresql.org'" Subject: Re: Problem with FOR SELECT in plpgsql function Date: Fri, 20 Feb 2004 11:09:32 +0000 User-Agent: KMail/1.5 References: <418DEFFAA399D311818A00508B912F2801A9F748@idefix.lvh.dnet.it> In-Reply-To: <418DEFFAA399D311818A00508B912F2801A9F748@idefix.lvh.dnet.it> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402201109.32849.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/300 X-Sequence-Number: 16990 On Friday 20 February 2004 10:07, Plant Thomas wrote: > I have a problem with the following function: [snip] > > This function sometimes returns null even if there is a record in the > database for the corrisponding id. > This happens only when there is only one record for the corrisponding id > value in the database, if there > are more than one record it works with no problem. If it actually returns NULL and not the empty string, then the loop must be processed, since you set "uhrzeiten" to the empty string before the loop. Two things to check: 1. None of your variables match a column in your select (and you seem OK here). 2. None of the fields in your expression are null (e.g. dat.vormittag_a) I think it's #2 - concat NULL to any string and you get NULL back. -- Richard Huxton Archonet Ltd