Re: [SQL] Re: SQL error: function round(double precision, integer) does not exist

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] Re: SQL error: function round(double precision, integer) does not exist
Дата
Msg-id 16285.1495736557@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [SQL] Re: SQL error: function round(double precision, integer)does not exist  (Vladimir Nicolici <vladnc@gmail.com>)
Ответы Re: [SQL] Re: SQL error: function round(double precision, integer)does not exist  (Vladimir Nicolici <vladnc@gmail.com>)
Список pgsql-sql
Vladimir Nicolici <vladnc@gmail.com> writes:
> I do that, but it’s extremely annoying.

Well, if it rises to the level of extreme annoyance for you, there
is a simple solution:

create function round(float8, int) returns numeric as
'select round($1::numeric, $2)' language sql;

> Furthermore, since the single parameter version accepts double precision numbers, the imprecise representation excuse
seemsquestionable at best.
 

The single-parameter version always rounds to integer, which avoids the
problem of not being able to represent decimal fractions exactly.
        regards, tom lane



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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: [SQL] Re: SQL error: function round(double precision, integer)does not exist
Следующее
От: Vladimir Nicolici
Дата:
Сообщение: Re: [SQL] Re: SQL error: function round(double precision, integer)does not exist