X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id 83DF0CCE16 for ; Fri, 18 Jul 2003 21:15:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 67634-10 for ; Fri, 18 Jul 2003 21:15:45 +0000 (GMT) Received: from mail2.n2bb.com (mail2.n2bb.com [66.0.13.202]) by svr1.postgresql.org (Postfix) with ESMTP id C2417CCE04 for ; Fri, 18 Jul 2003 18:15:13 -0300 (ADT) Received: from poopelstilskin.it.n2bb.com ([10.250.10.96] unverified) by mail2.n2bb.com with Microsoft SMTPSVC(5.0.2195.4905); Fri, 18 Jul 2003 17:17:02 -0400 Content-Type: text/plain; charset="us-ascii" From: Mike Rylander Reply-To: miker@n2bb.com Organization: N2 Broadband To: pgsql-sql@postgresql.org Subject: casting to arrays Date: Fri, 18 Jul 2003 17:07:48 -0400 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200307181707.48441.miker@n2bb.com> X-OriginalArrivalTime: 18 Jul 2003 21:17:02.0086 (UTC) FILETIME=[EE483A60:01C34D71] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/262 X-Sequence-Number: 14376 I have a rather odd table structure that I would like to simplify to be a view (for some definition of simplify). The current idea I have is to shovel values from multiple rows in one table into an array in the view. The tables look something like this: create table person ( id serial, name varchar ); create table stuff ( person_id references person (id) on delete restrict, stuff_name varchar ); The view would go something like: create view person_with_stuff as select p.id as id, p.name as name, ( select s.stuff_name from stuff where s.person_id = p.id )::varchar[] from person p; Is anything like this possible? I know this may not be good form, but unfortunately (or perhaps fortunately, since it means I have a job) there are business reasons for this, supporting old apps and such. Thanks in advance! -- Mike Rylander