format() function with string_agg - Mailing list pgsql-admin

From Raj Gandhi
Subject format() function with string_agg
Date
Msg-id CALU_HCOEBFAibCcCSBGKdGL7+Shd5vSZLGVBe6XqmM77SanUJA@mail.gmail.com
Whole thread Raw
Responses Re: format() function with string_agg
List 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 by date:

Previous
From: Jeff Frost
Date:
Subject: Re: Clarification on pg_basebackup
Next
From: David G Johnston
Date:
Subject: Re: format() function with string_agg