coalesce and nvl question

From: Simon Windsor <simon(dot)windsor(at)cornfield(dot)org(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: coalesce and nvl question
Date: 2004-06-23 16:04:08
Message-ID: 1088006647.4211.5.camel@celt.cornfield.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

Is there a standard postgres method of replacing empty strings.

In Oracle, nvl handles nulls and empty strings, as does ifnull() in
MySQL, but with postgres coalesce only handles null strings.

If, not is the best solution to create a plpgsql function, ie

CREATE FUNCTION isEmpty (character varying, character varying) RETURNS
character varying
AS '
declare
fnRetTrue alias for $1;
fnRetFalse alias for $2;
begin
if fnRetTrue = '' or fnRetTrue is not null then
return fnRetTrue;
else
return fnRetFalse;
end if;
end;
'
LANGUAGE plpgsql;

Thanks

Simon

--
Simon Windsor
Email: simon(dot)windsor(at)cornfield(dot)org(dot)uk
Tel: 01454 617689
Mob: 07960 321599

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Mailscanner thanks transtec Computers for their support.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2004-06-23 16:26:56 Re: RHEL 2.1 rpms for 7.4.2
Previous Message Dave Cramer 2004-06-23 15:57:58 Re: RHEL 2.1 rpms for 7.4.2