Search Postgresql Archives

Re: variable value in array_to_string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux