Re: Needed function IF(expr, expr, expr)

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Needed function IF(expr, expr, expr)
Дата
Msg-id Pine.LNX.4.44.0309061603250.1243-100000@peter.localdomain
обсуждение исходный текст
Ответ на Needed function IF(expr, expr, expr)  ("Marek Lewczuk" <newsy@lewczuk.com>)
Ответы Re: Needed function IF(expr, expr, expr)
Re: Needed function IF(expr, expr, expr)
Список pgsql-general
Marek Lewczuk writes:

> I'm moving out from MySQL to PostgreSQL and there are some function
> which are not supported in PG so I'm trying to write my own functions.
> Currently I have big problem with function IF(), below the description
> of this function from MySQL manual.

You cannot implement this kind of function, unless you want to create one
version for each data type combination.  But consider replacing the IF()
function with the standard CASE expression:

CASE WHEN expr1 THEN expr_if_true ELSE expr_if_false END

Also note that in PostgreSQL there is a boolean type, and 0 and 1 are not
valid boolean values.

--
Peter Eisentraut   peter_e@gmx.net


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

Предыдущее
От: "Marek Lewczuk"
Дата:
Сообщение: Needed function IF(expr, expr, expr)
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Needed function IF(expr, expr, expr)