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

2017-10-25 Thread Celia McInnis
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 wrote: > "David G. Johnston" writes: > > On Wed, Oct 25, 2017 at 2:16 PM, Celia

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

2017-10-25 Thread Tom Lane
"David G. Johnston" writes: > On Wed, Oct 25, 2017 at 2:16 PM, Celia McInnis >> 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

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

2017-10-25 Thread David G. Johnston
On Wed, Oct 25, 2017 at 2:16 PM, Celia McInnis wrote: > 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

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

2017-10-25 Thread Celia McInnis
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... On Wed, Oct 25, 2017 at 3:47 PM, Tom Lane wrote: > Celia McInnis

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

2017-10-25 Thread Celia McInnis
Thanks Tom - I saw how to do that for specified data, but I want to select the elements from a table of composite and don't know how to do that. I can't do insertions manually of each row separately! So how do I get material from my table of composite values into my table of array values? I am

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

2017-10-25 Thread Tom Lane
Celia McInnis writes: > My first question is: HOW do I populate this table, at first with arrays > containing one element from the t_composite table? > I have tried various things with no success. You didn't say what you tried, but I imagine it was something like

[GENERAL] How do I insert and update into a table of arrays of composite types via a select command?

2017-10-25 Thread Celia McInnis
I have a composite type like this, for example: create type mytype(a text, b text, c text); and a table create table t_cols(a text,b text,c text); containing some data. I have a table with my composite type: create table t_composite(data_comp mytype); and loaded data into it like so: insert