Received: from frithjof.reiner (c19.dialin.tuwien.ac.at [192.35.243.29]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id eBUHPaL99082 for ; Sat, 30 Dec 2000 12:25:36 -0500 (EST) (envelope-from areiner@tph.tuwien.ac.at) Received: (qmail 1044 invoked by uid 500); 30 Dec 2000 11:20:42 -0000 From: "Albert REINER" Date: Sat, 30 Dec 2000 12:20:42 +0100 To: PostgreSQL-SQL Subject: PL/pgSQL: returning array? Message-ID: <20001230122042.A1020@frithjof> Mail-Followup-To: PostgreSQL-SQL Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Archive-Number: 200012/309 X-Sequence-Number: 649 Saluton, I am trying to write my first plpgsql-functions; I do not seem to be able to find a way of returning an array; here is what I tried: ,---- | CREATE FUNCTION "concatallinstances2" (int4 ) RETURNS text[2] AS ' | declare | reslt text; | separator text; | instance record; | first text; | begin | reslt := ''''; | separator := ''''; | for instance in select cat from t where id = $1 order by cat LOOP | if first is null then | first := instance.cat; | end if; | reslt := reslt || separator || instance.cat; | separator := '', ''; | end loop; | return {first,reslt}; | end; | ' LANGUAGE 'plpgsql'; `---- I also tried `... RETURNS text[] ...' and `... RETURNS text_ ...' (I think I have read somewhere that the array type is given by basetype plus underscore) - none of these seem to work. I am using: ,---- | cgitest=> select version(); | version | -------------------------------------------------------------------- | PostgreSQL 7.0.2 on i586-pc-linux-gnulibc1, compiled by gcc 2.95.1 | (1 row) `---- I hope you can help me; thanks in advance - Albert. -- -------------------------------------------------------------------------- Albert Reiner Deutsch * English * Esperanto * Latine --------------------------------------------------------------------------