Re: coalesce for null AND empty strings

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Ferdinand Gassauer <gassauer(at)kde(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: coalesce for null AND empty strings
Date: 2007-03-30 08:41:45
Message-ID: 460CCD49.7070201@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ferdinand Gassauer wrote:
> Hi!
>
> it would be great to have a coalesce2 function which treats empty strings as
> null values.

I think

COALESCE(NULLIF(value1, ''), value2)

does what you want. You could wrap that in a new function coalesce2 if
you like.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Csaba Kalman 2007-03-30 08:59:14 PANIC: unexpected hash relation size
Previous Message Richard Huxton 2007-03-30 08:19:35 Re: coalesce for null AND empty strings