Re: [GENERAL] How do I insert and update into a table of arrays of composite types via a select command? - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] How do I insert and update into a table of arrays of composite types via a select command?
Date
Msg-id 25479.1508966720@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] How do I insert and update into a table of arrays ofcomposite types via a select command?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: [GENERAL] How do I insert and update into a table of arrays ofcomposite types via a select command?  (Celia McInnis <celia.mcinnis@gmail.com>)
List pgsql-general
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, Oct 25, 2017 at 2:16 PM, Celia McInnis <celia.mcinnis@gmail.com>
>> Got it, finally...
>> insert into t_array select array[row((data_comp).*)::mytype[] from
>> t_composite;
>>
>> I'm not sure why I need (data_comp).* rather than some of the other things
>> that I tried and failed with...

> ​The ​unusual set of parentheses are so the parser interprets data_comp is
> a column and not a table. Usually one write SELECT tbl.* FROM tbl so that
> is the assumed meaning of "name".*

If data_comp is a column of a composite type, you probably don't need all
that notation anyway --- seems like array[data_comp::my_type] or
array[data_comp]::my_type[] ought to work.
        regards, tom lane


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: [GENERAL] How do I insert and update into a table of arrays ofcomposite types via a select command?
Next
From: Celia McInnis
Date:
Subject: Re: [GENERAL] How do I insert and update into a table of arrays ofcomposite types via a select command?