tags:

views:

52

answers:

2

HI,

I need to form a string from a given array.

IF array[1] = gvk, array[2] = gvk1 and array[3] = gvk2 i need to get these values into a string like:

Mystring = gvk | gvk1 | gvk2

A: 

The MS SQL to POSTGRES Blogspot has a demonstration of how to implement a group_concat function in Postgres. It should be pretty straightforward to modify it to include a separator

Mark Baker
+2  A: 

I think you can use the array_to_string function here :

array_to_string(anyarray, text) --> text
concatenates array elements using supplied delimiter

e.g. array_to_string(ARRAY[1, 2, 3], '~^~') --> 1~^~2~^~3

Peter Tillemans