From: | "Armand Pirvu (home)" <armand(dot)pirvu(at)gmail(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | variable value in array_to_string |
Date: | 2016-11-21 22:09:51 |
Message-ID: | 9A6EE1AD-CC3C-4425-98D8-F117B3DBBCDF@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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_column_usage d '
||
'where c.constraint_name=d.constraint_name and c.table_name=d.table_name and c.table_schema='
||
quote_literal(‘myschema')
||
' and c.table_schema=d.table_schema and c.constraint_name like '
||
quote_literal('%_pkey%')
||
') ' into foo;
raise notice '%', foo;
foo1 :=ARRAY_TO_STRING(foo, ', ');
raise notice '%', foo1;
END;
$$ LANGUAGE plpgsql ;
The idea is that I want to slice and dice and not run the query x amount of times
Thank you
Armand
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2016-11-21 22:26:36 | Re: variable value in array_to_string |
Previous Message | Kevin Grittner | 2016-11-21 18:34:20 | Re: pg_class (system) table increasing size. |