coalesce and nvl question - Mailing list pgsql-general

From Simon Windsor
Subject coalesce and nvl question
Date
Msg-id 1088006647.4211.5.camel@celt.cornfield.org.uk
Whole thread Raw
Responses Re: coalesce and nvl question  (Mike Mascari <mascarm@mascari.com>)
List 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.windsor@cornfield.org.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.


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: FW: problems with installing postgres
Next
From: Dave Cramer
Date:
Subject: Re: RHEL 2.1 rpms for 7.4.2