X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E7D4347626E for ; Tue, 4 Mar 2003 13:00:54 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 53162-04 for ; Tue, 4 Mar 2003 13:00:53 -0500 (EST) Received: from bach.ccinet.ab.ca (bach.ccinet.ab.ca [198.161.96.1]) by postgresql.org (Postfix) with ESMTP id CD4D7476242 for ; Tue, 4 Mar 2003 13:00:52 -0500 (EST) Received: from incentre.net (squid.incentre.net [206.75.213.195]) by bach.ccinet.ab.ca (8.12.6/8.12.6) with ESMTP id h24HwDJ7091213; Tue, 4 Mar 2003 10:58:14 -0700 (MST) (envelope-from guy@incentre.net) Message-ID: <3E64E93D.9050506@incentre.net> Date: Tue, 04 Mar 2003 10:58:21 -0700 From: Guy Fraser Organization: J I Reasearch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003 X-Accept-Language: en MIME-Version: 1.0 To: Edmund Lian Cc: pgsql-sql@postgresql.org Subject: Convert a text list to text array? Was: Denormalizing during select References: <200302241433.49502.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/119 X-Sequence-Number: 12159 The email at the bottom gave me an idea, but it doesn't quite work: CREATE AGGREGATE accumulate( BASETYPE = text, SFUNC = textcat, STYPE = text, INITCOND = '' ); -- SELECT ('{' || ltrim(accumulate(',' || tablename),',') || '}') as cruft FROM pg_tables WHERE hasindexes = 'f'; cruft --------------------------- {pg_xactlock,pg_listener} (1 row) This produces somthing that looks like it could be able to be converted into an array but I cant figure out how to make it work. Guy Edmund Lian wrote: > Jeff and Josh, > > I found this example in "Practical PostgreSQL"... will it do the job? > > """ > The following example defines an aggregate function named sum(), for > use with the text data type. This aggregate calls the > textcat(text,text) function built into PostgreSQL to return a > concatenated "sum" of all the text found in its input values: > > booktown=# CREATE AGGREGATE sum ( BASETYPE = text, > booktown(# SFUNC = textcat, > booktown(# STYPE = text, > booktown(# INITCOND = '' ); > CREATE > booktown=# SELECT sum(title || ' ') FROM books WHERE title ~ '^L'; ...snip...