Re: Problems with using function input paramaters

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Problems with using function input paramaters
Дата
Msg-id 23260.1567264410@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Problems with using function input paramaters  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Sat, Aug 31, 2019 at 7:05 AM stan <stanb@panix.com> wrote:
>> CURRENT_DATE) - interval '  $1
>> month - 1
>> ' day as date)

> ($1 || ' month')::interval  -- should work

FWIW, I tend to prefer doing it with interval arithmetic, like this:

$1 * '1 month'::interval - '1 day'::interval

It's faster (not enormously so, but measurably) thanks to not having
to construct and then parse a text string.  To my mind it's easier
to reason about, too, and a bit safer.

            regards, tom lane



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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Problems with using function input paramaters
Следующее
От: stan
Дата:
Сообщение: echo work alike in SQL