Re: [GENERAL] Populating array of composite datatype

2013-08-07 Thread John McKown
Just wanted to put a short thank you note in here. I've been using PostgreSQL for a while, but only using basic SQL. The information in this thread pointed me to the information that I needed to read about to solve a problem which has been tormenting me, off and on, for a couple of months. I just c

Re: [GENERAL] Populating array of composite datatype

2013-08-07 Thread David Johnston
Sameer Thakur wrote > insert into test values (ARRAY[abc(1,2)]); but got error When you use a function form of casting like this you are basically short-circuiting the type conversion mechanisms built into PostgreSQL by directly calling the conversion function instead of actually telling the syste

Re: [GENERAL] Populating array of composite datatype

2013-08-07 Thread Sameer Thakur
Thank you Raghavendra and Chris, both approaches work.

Re: [GENERAL] Populating array of composite datatype

2013-08-07 Thread Raghavendra
> On Wed, Aug 7, 2013 at 3:53 AM, Raghavendra < > raghavendra@enterprisedb.com> wrote: > >> >> postgres=# insert into foo values (array[row(1,2)::abc]); >> >> > Also because all array members must be of the same db type, you can: > > insert into foo values (array[row(1,2)]::abc[]). This can be

Re: [GENERAL] Populating array of composite datatype

2013-08-07 Thread Chris Travers
On Wed, Aug 7, 2013 at 3:53 AM, Raghavendra < raghavendra@enterprisedb.com> wrote: > > postgres=# insert into foo values (array[row(1,2)::abc]); > > Also because all array members must be of the same db type, you can: insert into foo values (array[row(1,2)]::abc[]). This can be helpful if yo

Re: [GENERAL] Populating array of composite datatype

2013-08-07 Thread Raghavendra
On Wed, Aug 7, 2013 at 4:04 PM, Sameer Thakur wrote: > Hello, > I have a composite datatype abc which has two integer fields x,y. > I have a table Test which has an array of abc. > I am trying to populate Test. Tried > insert into test values (ARRAY[abc(1,2)]); but got error > ERROR: function ab

[GENERAL] Populating array of composite datatype

2013-08-07 Thread Sameer Thakur
Hello, I have a composite datatype abc which has two integer fields x,y. I have a table Test which has an array of abc. I am trying to populate Test. Tried insert into test values (ARRAY[abc(1,2)]); but got error ERROR: function abc(integer, integer) does not exist Is there anyway for doing this?