From: | Celia McInnis <celia(dot)mcinnis(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How do I insert and update into a table of arrays of composite types via a select command? |
Date: | 2017-10-25 21:33:53 |
Message-ID: | CAGD6t7J1fGBUmJ2Ag5Wo4GqcRbYrwioH9AggOKrVhi7-3F4i_w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Yes, thanks - that's nicer - I am now using:
insert into t_array select array[data_comp]::mytype[] from t_composite;
On Wed, Oct 25, 2017 at 5:25 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> > On Wed, Oct 25, 2017 at 2:16 PM, Celia McInnis <celia(dot)mcinnis(at)gmail(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2017-10-26 07:02:43 | Re: query not scaling |
Previous Message | Tom Lane | 2017-10-25 21:25:20 | Re: How do I insert and update into a table of arrays of composite types via a select command? |