Re: variable value in array_to_string

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: variable value in array_to_string
Дата
Msg-id CAKFQuwaujAm+fSNP8NYXxVD-t7FKn81_9BY5+zmEj9q_S5VR+Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: variable value in array_to_string  ("Armand Pirvu (home)" <armand.pirvu@gmail.com>)
Список pgsql-general
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 your question is which is maybe why I'm coming across as patronizing.  And while I get that what you wrote is technically correct its using capabilities that have since be superseded by more readable and less error-prone facilities.

The docs do explain this material in terms of technical capabilities.  For better and worse it doesn't always go to great lengths (or keeps up with changing times) to describe best practices or how multiple pieces fit together.

​I'm also thinking that your original question is more accurately worded:  Is there anyway I can [use an expression] in the array_to_string function 

I'm not nit-picking here - the word variable when you writing a pl/pgsql language function has a very specific meaning which is not <'a.' || column_name>

In both cases the answer is a simple yes.  Sorry for causing pain by offering up more information than requested.  Its bad habit of mine - trying to provide related information when presented with a question.

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: "Armand Pirvu (home)"
Дата:
Сообщение: Re: variable value in array_to_string
Следующее
От: Mark Anns
Дата:
Сообщение: How to open PGStrom (an extension of PostgreSQL) in Netbeans?