coalesce and nvl question

Поиск
Список
Период
Сортировка
От Simon Windsor
Тема coalesce and nvl question
Дата
Msg-id 1088006647.4211.5.camel@celt.cornfield.org.uk
обсуждение исходный текст
Ответы Re: coalesce and nvl question  (Mike Mascari <mascarm@mascari.com>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: FW: problems with installing postgres
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: RHEL 2.1 rpms for 7.4.2