Thread: PL/pgSQL Syntax Problem
Hi, this function: CREATE FUNCTION t_nummern(integer) -- Parameter: lfd_nr RETURNS text AS ' DECLARE lfd_nr ALIAS FOR $1; erg text; daten record; BEGIN erg := ''''; FOR daten IN SELECT * INTO daten FROM telefon WHERE t_lfd_nr = lfd_nr LOOP IF erg <> '''' THEN erg := erg || '', ''; END IF; IF daten.t_einrichtg <> '''' THEN erg := erg || daten.t_einrichtg || '': ''; END IF; erg := erg || ''('' || daten.vorwahl || '') '' || daten.telefon_nr; END LOOP; RETURN erg; END;' LANGUAGE 'plpgsql'; causes the following error: mitglieder=> select t_nummern(330); ERROR: query "SELECT * INTO daten FROM telefon WHERE t_lfd_nr = $1 " isn't a SELECT mitglieder=> Why isn't this a SELECT?? Thanks in advance, -- Hubert Palme Am Walde 1 42119 Wuppertal <hubert.palme@web.de>
The syntax is: SELECT INTO daten * FROM telefon WHERE t_lfd_nr = lfd_nr DAQ
Thanks to all who answered -- you solved my problemn :-) Hubert > Hubert Palme wrote: >> Hi, >> >> this function: >> >> CREATE FUNCTION t_nummern(integer) -- Parameter: lfd_nr >> RETURNS text AS ' >> DECLARE >> lfd_nr ALIAS FOR $1; >> erg text; >> daten record; >> BEGIN >> erg := ''''; >> FOR daten IN >> SELECT * INTO daten FROM telefon WHERE t_lfd_nr = lfd_nr >> LOOP >> IF erg <> '''' THEN >> erg := erg || '', ''; >> END IF; >> IF daten.t_einrichtg <> '''' THEN >> erg := erg || daten.t_einrichtg || '': ''; >> END IF; >> erg := erg || ''('' || daten.vorwahl || '') '' || daten.telefon_nr; >> END LOOP; >> RETURN erg; >> END;' >> LANGUAGE 'plpgsql'; >> >> causes the following error: >> >> mitglieder=> select t_nummern(330); >> ERROR: query "SELECT * INTO daten FROM telefon WHERE t_lfd_nr = $1 " >> isn't a >> SELECT >> mitglieder=> >> >> Why isn't this a SELECT?? -- Hubert Palme Am Walde 1 42119 Wuppertal <hubert.palme@web.de>