format() function with string_agg

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

 



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






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux