Received: from multivac (multivac.embryo.se [195.149.181.2]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9UL5KP44042 for ; Tue, 30 Oct 2001 16:05:21 -0500 (EST) (envelope-from tobbe@embryo.se) Received: from tuba.embryo.se ([172.16.0.67]) by multivac with esmtp (Exim 3.12 #1 (Debian)) id 15yg4Y-0006Fv-00 for ; Tue, 30 Oct 2001 22:05:22 +0100 User-Agent: Microsoft-Entourage/9.0.1.3108 Date: Tue, 30 Oct 2001 22:05:15 +0100 Subject: Strange loop From: Torbj=?ISO-8859-1?B?9g==?=rn Andersson To: Message-ID: In-Reply-To: <20011031025141.402B.RK73@echna.ne.jp> Mime-version: 1.0 Content-type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by postgresql.org id f9ULLrM47446 X-Archive-Number: 200110/421 X-Sequence-Number: 5372 Hi, I need some help with the function below. My intention is to hand the content of result_store and sort it out so that I can have a complete recordset. But for some reason result_store is returned empty. It works fine for one row but the concatenation of result_store and result does not seem to work. Can some one pleas explain why? CREATE FUNCTION f_snus() RETURNS varchar AS ' DECLARE result varchar; result_store varchar; row record; BEGIN FOR row IN SELECT snus_id, namn, betyg FROM snus ORDER BY betyg LOOP SELECT INTO result row.snus_id || ''\t'' || row.namn || ''\t'' || row.betyg || ''\n''; result_store := result_store || result; END LOOP; RETURN result_store; END; ' LANGUAGE 'PLPGSQL'; Regards Torbjörn Andersson --------------------------------------------------- Embryo Communication phone: +46 (0) 31-774 39 11(00) Kungsgatan 7a fax: +46 (0)31 774 07 80 S-411 19 Göteborg mobile: 0708-30 70 04 Sweden home: http://www.embryo.se/ mail: torbjorn.andersson@embryo.se --------------------------------------------------- "Att idag tänka annorlunda än igår skiljer den vise från den envise." — John Steinbeck