Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread David G. Johnston
For what its worth: DO $$ DECLARE vresult text; begin EXECUTE $qry$ WITH cols (c) AS ( VALUES ('col1'),('col2') ) SELECT string_agg('a.' || cols.c, ',') FROM cols WHERE 'foo' = $1 $qry$ USING 'foo' INTO vresult; RAISE NOTICE '%', vresult; END; $$; I still haven't actually figured out what

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread Armand Pirvu (home)
1 - I added some new notes. 2 - That code I know and works fine. I used it in slightly different contexts in other projects Here it is a case . A table with two columns , data type is irrelevant I have a need in which I may get a.col1,a.col2 and other variations Point is yes I could build a

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread David G. Johnston
Please don't top-post - it makes following the thread a lot harder. On Mon, Nov 21, 2016 at 4:15 PM, Armand Pirvu (home) wrote: > Played with unnest but not much luck > If you want help you will need to show your work - ideally with examples that can execute with meaningful data on an empty da

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread Armand Pirvu (home)
Played with unnest but not much luck NOTICE: {item_id,show_id} NOTICE: item_id It takes only the first array element in consideration Ug On Nov 21, 2016, at 5:02 PM, Armand Pirvu (home) wrote: > My bad on the back tick. No idea why it turned that way > > OK got that David. > > Th

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread Armand Pirvu (home)
My bad on the back tick. No idea why it turned that way OK got that David. The idea is that I have the pk columns in an array which I would like to manipulate from the array itself rather than running same query variations multiple times For example I get in foo {item_id,show_id} And from h

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread David G. Johnston
On Mon, Nov 21, 2016 at 3:09 PM, Armand Pirvu (home) wrote: > Hi > > Is there anyway I can pass a variable in the array_to_string function ? > > ​Yes, just like you can pass variables to any other function.​.. > CREATE OR REPLACE FUNCTION test1 () RETURNS void AS $$ > ​​ > DECLARE > foo text; >

[GENERAL] variable value in array_to_string

2016-11-21 Thread Armand Pirvu (home)
Hi Is there anyway I can pass a variable in the array_to_string function ? CREATE OR REPLACE FUNCTION test1 () RETURNS void AS $$ DECLARE foo text; foo1 text; begin execute 'select ARRAY( SELECT d.COLUMN_NAME::text from information_schema.constraint_table_usage c, information_schema.key_co