Is there a conditional string-concatenation ?

Поиск
Список
Период
Сортировка
От Andreas
Тема Is there a conditional string-concatenation ?
Дата
Msg-id 4CB3DF63.6080909@gmx.net
обсуждение исходный текст
Ответы Re: Is there a conditional string-concatenation ?  (Joshua Tolley <eggyknap@gmail.com>)
Re: Is there a conditional string-concatenation ?  (Osvaldo Kussama <osvaldo.kussama@gmail.com>)
Список pgsql-sql
  Hi,
Is there a conditional string-concatenation ?

I'd like to have an elegant way to connect 2 strings with some 3rd 
element between only if there really are 2 strings to connect.

e.g.
MyCat ( 'John', '_', 'Doe' ) --> 'John_Doe'
while
MyCat ( 'John', '_', '' ) --> 'John'
MyCat ( '', '_', 'Doe' ) --> 'Doe'
MyCat ( '', '_', '' ) --> NULL

It should treat  NULL  and  ''  equally as empty
and it should trim each of the 3 elements.

so
MyCat ( '       John     ', '_', NULL ) --> 'John'
MyCat ( 'John', NULL, 'Doe' ) --> 'JohnDoe'




В списке pgsql-sql по дате отправления:

Предыдущее
От: Markus Schatten
Дата:
Сообщение: Re: get attribute from XML
Следующее
От: Joshua Tolley
Дата:
Сообщение: Re: Is there a conditional string-concatenation ?