Re: coalesce for null AND empty strings

From: Ferdinand Gassauer <gassauer(at)kde(dot)org>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: coalesce for null AND empty strings
Date: 2007-03-30 11:54:21
Message-ID: 200703301354.22221.gassauer@kde.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

--
cu
ferdinand

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Teodor Sigaev 2007-03-30 12:01:48 Re: Tsearch2 crashes my backend, ouch !
Previous Message Listmail 2007-03-30 11:20:30 Tsearch2 crashes my backend, ouch !