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 ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match