Re: Re[2]: AW: [HACKERS] isnull() or is it?t

Поиск
Список
Период
Сортировка
От jwieck@debis.com (Jan Wieck)
Тема Re: Re[2]: AW: [HACKERS] isnull() or is it?t
Дата
Msg-id m0zoCfZ-000EBQC@orion.SAPserv.Hamburg.dsh.de
обсуждение исходный текст
Ответ на Re[2]: AW: [HACKERS] isnull() or is it?t  (Sferacarta Software <sferac@bo.nettuno.it>)
Список pgsql-hackers
>
> If it is interesting to someone, we can partially emulate COALESCE
> right now as:
>
> create function coalesce(integer) returns integer as
> 'declare
>         nonullo alias for $1;
> begin
>      if nonullo then
>         return nonullo;
>      else
>         return 0;
>      end if;
>  end;
> ' language 'plpgsql';
> CREATE

    Pardon,  but  you  still  misuse the fact, that PL/pgSQL's IF
    expression is implicitly casted into a boolean.  That's  only
    possible for integer values.

    Please use

        IF nonullo ISNULL THEN
            RETURN 0;
        ELSE
            RETURN nonullo;
        END IF;

    instead,  because this would work for other types (like text,
    varchar etc.)  too.

    Since PL functions can be overloaded (like SQL functions), it
    would  be possible, but currently not that performant :-(, to
    create such a function for all types required.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Frank Ridderbusch
Дата:
Сообщение: subscribe
Следующее
От: Dan Gowin
Дата:
Сообщение: RE: [HACKERS] PgAccess version 0.93 (for Unix and Windows) has be en released!