Re: coalesce for null AND empty strings - Mailing list pgsql-general

From Richard Huxton
Subject Re: coalesce for null AND empty strings
Date
Msg-id 460CFC8D.2040206@archonet.com
Whole thread Raw
In response to coalesce for null AND empty strings  (Ferdinand Gassauer <gassauer@kde.org>)
Responses Re: coalesce for null AND empty strings  (Lew <lew@nospam.lewscanon.com>)
List pgsql-general
Ferdinand Gassauer wrote:
> On Friday 30 March 2007 10:19:35 Richard Huxton wrote:
>> Don't forget to cc: the list!
>
> snip
>>> OK this shortens the function, but does not help to "solve"  the coalesce
>>> problem
>>> coalecse(empty2null(var1),empty2null(var2),....empty2null(var-n))
>>> instead of
>>> coalecse2(var1,var2,...var-n)
>>>
>>> where the empty2null is doing it's job "inside" the coalesce.
>> Well, you can always write the four or five variations you want:
>> CREATE OR REPLACE FUNCTION coalesce_and_blank(varchar) ...
>> CREATE OR REPLACE FUNCTION coalesce_and_blank(varchar,varchar) ...
>> CREATE OR REPLACE FUNCTION coalesce_and_blank(varchar,varchar,varchar) ...
> OK - this is a solution I didn't think off , because other system do not allow
> this sort of "overloading".
>
> Nevertheless I think
> * coalesce takes n arguments, which would need the user to write n functions
> to fully cover the functionality - even though I think it's seldom to have
> more than 4-5 arguments.
> * looking through Google it IS a concern for many others and thus this
> function should be distributed as default.

Hmm - I see it coming up occasionally, but usually where people are
misusing NULLs.

What you might want to do is tidy up a function and post it to the list
for the record. Or, you could start a project on pgfoundry to share it.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Teodor Sigaev
Date:
Subject: Re: Tsearch2 crashes my backend, ouch !
Next
From: Teodor Sigaev
Date:
Subject: Re: Tsearch2 crashes my backend, ouch !