Re: [GENERAL] Update multiple rows in a table with different values

2016-07-01 Thread shankha
; $$ LANGUAGE plpgsql; Is there a better way to do it using : unnest. Thanks Shankha Banerjee On Fri, Jul 1, 2016 at 10:59 AM, Tom Lane wrote: > shankha writes: >> PREPARE updatearrayplan(BigInt[], BigInt[]) AS >> for i in size($1) >> DO >> upd

Re: [GENERAL] Update multiple rows in a table with different values

2016-07-01 Thread shankha
. I do not know the exact syntax. Sorry for the confusion. Thanks Shankha Banerjee On Fri, Jul 1, 2016 at 10:48 AM, Adrian Klaver wrote: > On 07/01/2016 07:26 AM, shankha wrote: >> >> Greetings, >> I have the following schema: >> >> CREATE TABLE "s&qu

[GENERAL] Update multiple rows in a table with different values

2016-07-01 Thread shankha
Greetings, I have the following schema: CREATE TABLE "s"."t1" ( "c1" BigSerial PRIMARY KEY, "c2" BigInt NOT NULL, "c3" BigInt ) WITH (OIDS=FALSE); INSERT INTO s.t1 (c2, c3) VALUES (10, 100); INSERT INTO s.t1 (c2, c3) VALUES (20, 200); INSERT INT

Re: [GENERAL] Use of array_agg and array string on inner query

2016-05-19 Thread shankha
I got the query: SELECT c1, c2, ARRAY_TO_STRING(ARRAY_AGG((SELECT t3.c1 FROM s.t1 as t3 JOIN s.t1 as t2 ON t3.c3 = t2.c2)), ',') FROM s.t1 t1 GROUP BY c1; DROP SCHEMA s CASCADE; Thanks for all the help. Thanks Shankha Banerjee On Wed, May 18, 2016 at 2:40 PM, David G. Johnston w

Re: [GENERAL] Use of array_agg and array string on inner query

2016-05-18 Thread shankha
I cannot move the array_agg to around the column name. It has to work as a inner query. I will try out your other suggestion. Thanks Shankha Banerjee On Wed, May 18, 2016 at 2:26 PM, Sameer Kumar wrote: > > > On Thu, 19 May 2016, 2:07 a.m. shankha, wrote: >> >>

Re: [GENERAL] Use of array_agg and array string on inner query

2016-05-18 Thread shankha
, ARRAY_TO_STRING(ARRAY_AGG((SELECT t3.c1 FROM s.t1 as t3 JOIN s.t1 as t2 ON t3.c3 = t2.c2)), ',') FROM s.t1 t1 GROUP BY c1; DROP SCHEMA s CASCADE; to get me the output desired. Thanks Shankha Banerjee On Wed, May 18, 2016 at 1:57 PM, Sameer Kumar wrote: > >

[GENERAL] Use of array_agg and array string on inner query

2016-05-18 Thread shankha
I have the following piece of code: DROP SCHEMA IF EXISTS s CASCADE; CREATE SCHEMA s; CREATE TABLE "s"."t1" ( "c1" BigSerial PRIMARY KEY, "c2" BigInt NOT NULL, "c3" BigInt ) WITH (OIDS=FALSE); INSERT INTO s.t1 (c2) VALUES (10); INSERT INTO