Problem with FOR SELECT in plpgsql function - Mailing list pgsql-sql

From Plant Thomas
Subject Problem with FOR SELECT in plpgsql function
Date
Msg-id 418DEFFAA399D311818A00508B912F2801A9F748@idefix.lvh.dnet.it
Whole thread Raw
Responses Re: Problem with FOR SELECT in plpgsql function  (Richard Huxton <dev@archonet.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "2000info"
Date:
Subject: pg_restore - don´t restore. Why?
Next
From: Richard Huxton
Date:
Subject: Re: Problem with FOR SELECT in plpgsql function