Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLFQ0-0002Re-QD for pgsql-sql@postgresql.org; Mon, 08 Oct 2012 15:38:56 +0000 Received: from cicero1.cybercity.dk ([212.242.40.4]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLFPy-0004QC-LE for pgsql-sql@postgresql.org; Mon, 08 Oct 2012 15:38:56 +0000 Received: from jukebox.alleroedderne.adsl.dk (port161.ds1-aroe.adsl.cybercity.dk [217.157.138.230]) by cicero1.cybercity.dk (Postfix) with ESMTP id 9249C108A80 for ; Mon, 8 Oct 2012 17:38:53 +0200 (CEST) Received: from localhost (jukebox.alleroedderne.adsl.dk [127.0.0.1]) by jukebox.alleroedderne.adsl.dk (Postfix) with ESMTP id 6A1796AA0A for ; Mon, 8 Oct 2012 17:38:53 +0200 (CEST) X-Virus-Scanned: amavisd-new at alleroedderne.adsl.dk Received: from jukebox.alleroedderne.adsl.dk ([127.0.0.1]) by localhost (jukebox.alleroedderne.adsl.dk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id SuNzMnhPg3jn for ; Mon, 8 Oct 2012 17:38:47 +0200 (CEST) Received: from kim.alleroedderne.adsl.dk (kim [192.168.0.3]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by jukebox.alleroedderne.adsl.dk (Postfix) with ESMTPS id 8BAA96A26A for ; Mon, 8 Oct 2012 17:38:47 +0200 (CEST) Message-ID: <5072F386.3020802@alleroedderne.adsl.dk> Date: Mon, 08 Oct 2012 17:38:46 +0200 From: Kim Bisgaard User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Error 42704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/31 X-Sequence-Number: 36902 Hi, I am trying to model a macro system where I have simple things, and more complex thing consisting of simple things. To do that I have "invented" this table definition: CREATE TABLE params ( param_id serial NOT NULL, name text NOT NULL, unit text, real_param_id integer[], CONSTRAINT params_pkey PRIMARY KEY (param_id), CONSTRAINT params_name_key UNIQUE (name) ); with a complex and 2 simple things: INSERT INTO params VALUES (1, 'a', NULL, '{1,2}'); INSERT INTO params VALUES (2, 'a1', '1', NULL); INSERT INTO params VALUES (3, 'a2', '2', NULL); So I want to get a listing of things, both simple and complex col1 col2 -----+------------------------ a1 {{a1, 1}} a2 {{a2, 2}} a {{a1, 1},{a2,2}} with this SQL: select name, array[array[name::text,unit::text]]::text[][] from params where real_param_id is null union select name, array(select cast('{"'||a.name||'","'||a.unit||'"}' as text[]) from params a, (select c.param_id, unnest(real_param_id) from params c where c.param_id=b.param_id) as j where a.param_id = j.unnest) from params b where b.real_param_id is not null order by name But I am getting this error which I do not find very informative, as I know i can have arrays of text and arrays of those, so what is up? ERROR: could not find array type for data type text[] SQL state: 42704 Suggestions as to what to do to circumvent this error, and also to maybe more elegant ways to solve the fundamental problem will be received with pleasure. This is tested on both PostgreSQL 9.2.1 and a 9.1.* Thanks in advance! Regards, Kim