How concat 3 strings if 2 are not empty? - Mailing list pgsql-sql

From Andreas
Subject How concat 3 strings if 2 are not empty?
Date
Msg-id 499BF61D.1000605@gmx.net
Whole thread Raw
Responses Re: How concat 3 strings if 2 are not empty?
List pgsql-sql
Hi,

I'd like a function that concats 3 string parameters on condition the 
1st and 3rd are NOT empty or NULL.
xCat (s1, s2, s3)
s2 would be a connector that appears only if s1 and s3 are set.

NULL and an empty string '' should be handled the same.

e.g.
'PostgreSQL',  ' is ', ' great'    -->     'PostgreSQL is great'
NULL,  ' is ', ' great'              -->     'great'
'PostgreSQL',  ' is ', NULL    -->     'PostgreSQL'
NULL,  ' is ', NULL              -->     NULL
'PostgreSQL',  NULL, ' great'    -->     'PostgreSQL great'


Regards
Andreas


pgsql-sql by date:

Previous
From: Andreas
Date:
Subject: Re: Funtion to clean up strings?
Next
From: "A. Kretschmer"
Date:
Subject: Re: How concat 3 strings if 2 are not empty?