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 523AED1B4DE for ; Fri, 20 Feb 2004 10:07:32 +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 14344-04 for ; Fri, 20 Feb 2004 06:07:29 -0400 (AST) Received: from firewally.lvh.dnet.it (unknown [213.21.186.50]) by svr1.postgresql.org (Postfix) with ESMTP id 02C41D1B456 for ; Fri, 20 Feb 2004 06:07:25 -0400 (AST) Received: from idefix.lvh.dnet.it (idefix.lvh.dnet.it [192.168.1.11]) by firewally.lvh.dnet.it (8.12.3/8.12.3/Debian-6.6) with ESMTP id i1KA7N4H024548 for ; Fri, 20 Feb 2004 11:07:23 +0100 Received: by idefix.lvh.dnet.it with Internet Mail Service (5.5.2650.21) id <1GQWS1M0>; Fri, 20 Feb 2004 11:07:23 +0100 Message-ID: <418DEFFAA399D311818A00508B912F2801A9F748@idefix.lvh.dnet.it> From: Plant Thomas To: "'pgsql-sql@postgresql.org'" Subject: Problem with FOR SELECT in plpgsql function Date: Fri, 20 Feb 2004 11:07:22 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" X-LVH-APA-MailScanner-Information: Please contact the ISP for more information X-LVH-APA-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/299 X-Sequence-Number: 16989 I have a problem with the following function: CREATE OR REPLACE FUNCTION "weiterbildung"."f_termine_uhrzeit" (integer) RETURNS text AS' DECLARE id ALIAS for $1; dat RECORD; uhrzeiten text; BEGIN uhrzeiten = ''''; FOR dat IN SELECT vormittag_a, vormittag_e, nachmittag_a, nachmittag_e FROM weiterbildung.t_termine where id_kurs = id order by datum LOOP uhrzeiten := uhrzeiten||to_char(dat.vormittag_a,''HH24:MI'')||''(''||to_char(dat.vormitta g_a,''HH24:MI'')||''-''||to_char(dat.vormittag_e,''HH24:MI'')||'' ''||to_char(dat.nachmittag_a,''HH24:MI'')||''-''||to_char(dat.nachmittag_e,' 'HH24:MI'')||'')''; END LOOP; RETURN uhrzeiten; END; 'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; 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. Is there a bug in the FOR SELECT statement? Thanks for advice