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
ERROR: too few arguments for format
********** Error **********
ERROR: too few arguments for format
SQL state: 22023