array_combine() and narray_combine() functions

The array_combine() and narray_combine() functions combine the elements in an array into a single delimited varchar or nvarchar value.

Syntax

The array_combine() function has the following syntax:
varchar = array_combine(array input, char delimiter);
The narray_combine() function is the Unicode form of the function and has the following syntax:
nvarchar = narray_combine(array input, nchar delimiter);

The input value specifies the array to decompose into a single varchar or nvarchar value.

The delimiter value specifies the delimiter that distinguishes the array elements.

Returns

The functions return a single delimited varchar or nvarchar value.

Example

For example, the following two queries add two elements to the array in the array_t table, which was created in the array() function example:
update array_t set col2= add_element(col2,12);
UPDATE 1
update array_t set col2= add_element(col2,23);
UPDATE 1
You can use the following query to display the array elements separated by a vertical bar delimiter:
select array_combine(col2,'|')from array_t;
 array_combine 
---------------
 12|23
(1 row)