concat strings but spaces

From: Matthias Teege <matthias(at)mteege(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: concat strings but spaces
Date: 2004-03-30 08:23:20
Message-ID: slrnc6ibke.306f.matthias@one.mteege.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Moin,

I try to concat values from three fields in a function like this:

create or replace function
fconcat_name(varchar, varchar, varchar) returns varchar as '
declare
ttl alias for $1;
vnm alias for $2;
nme alias for $3;
begin
return ttl || '' '' || vnm || '' '' || nme;
end;
' language plpgsql;

That works but if one of the fields is empty there are to much
spaces in the result. Is there any alternative to a monster
if-then construct?

Many thanks
Matthias

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Wood 2004-03-30 09:55:18 Re: PG vs MySQL
Previous Message CoL 2004-03-30 08:18:15 Re: select first(...