Re: Is there a conditional string-concatenation ?

Поиск
Список
Период
Сортировка
От Joshua Tolley
Тема Re: Is there a conditional string-concatenation ?
Дата
Msg-id 4cb3e194.ea05ec0a.3e4b.06b2@mx.google.com
обсуждение исходный текст
Ответ на Is there a conditional string-concatenation ?  (Andreas <maps.on@gmx.net>)
Список pgsql-sql
On Tue, Oct 12, 2010 at 06:09:07AM +0200, Andreas wrote:
>  Hi,
> Is there a conditional string-concatenation ?

Perhaps this:

CREATE OR REPLACE FUNCTION mycat(text, text, text) RETURNS TEXT LANGUAGE sql
IMMUTABLE AS $$
SELECT CASE   WHEN $1 IS NULL OR $1 = '' THEN trim($3)   WHEN $3 IS NULL OR $3 = '' THEN trim($1)   ELSE trim($1) ||
trim(coalesce($2,'')) || trim($3)
 
END;

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

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

Предыдущее
От: Andreas
Дата:
Сообщение: Is there a conditional string-concatenation ?
Следующее
От: Osvaldo Kussama
Дата:
Сообщение: Re: Is there a conditional string-concatenation ?