From: Andreas <maps.on@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Is there a conditional string-concatenation ?
Date: Tue, 12 Oct 2010 06:09:07 +0200
Message-ID: <4CB3DF63.6080909@gmx.net> (raw)
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'
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: maps.on@gmx.net
Subject: Re: Is there a conditional string-concatenation ?
In-Reply-To: <4CB3DF63.6080909@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox