format() function with string_agg

Поиск
Список
Период
Сортировка
От Raj Gandhi
Тема format() function with string_agg
Дата
Msg-id CALU_HCOEBFAibCcCSBGKdGL7+Shd5vSZLGVBe6XqmM77SanUJA@mail.gmail.com
обсуждение исходный текст
Ответы Re: format() function with string_agg  (David G Johnston <david.g.johnston@gmail.com>)
Список pgsql-admin
I'm trying to use format() function with string_agg with Postgres 9.1.9 but getting error - "too few arguments for format"

I have two tables t_message and t_message_args. Table t_message   has 'message' column with text in the format 'Test message first arg is %1$s and second arg  %2$s end-of-message'

              id             | integer           |
              message | character varying |


And the second table t_message_args contains message argument and values 
              id           | integer           |
             arg          | integer           |
             argvalue  | character varying |


Here is the SQL that uses format() function to retrieve formatted message by replacing arg value in the message:
=
select m.id, format(m.message, string_agg(a.argvalue, ',' order by a.arg)
from t_message m, t_message_args a
where m.id = a.id
group by m.id, m.message


ERROR:  too few arguments for format

********** Error **********

ERROR: too few arguments for format
SQL state: 22023





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

Предыдущее
От: Jeff Frost
Дата:
Сообщение: Re: Clarification on pg_basebackup
Следующее
От: David G Johnston
Дата:
Сообщение: Re: format() function with string_agg