Re: Why overlaps is not working

Поиск
Список
Период
Сортировка
От Jorge Godoy
Тема Re: Why overlaps is not working
Дата
Msg-id 8764dos5sy.fsf@gmail.com
обсуждение исходный текст
Ответ на Re: Why overlaps is not working  ("Andrus" <eetasoft@online.ee>)
Список pgsql-general
"Andrus" <eetasoft@online.ee> writes:

> Jorge,
>
> Thank you very much. Now I try to William Leite Araújo solution by replacing
>
> WHERE (a,b) OVERLAPS (c,d)
>
> with
>
> WHERE  ( c BETWEEN a AND b ) OR  ( d BETWEEN a AND b )
>
> Is this OK ?

From bare tests this looks OK.

> This requires writing a and b expressions twice. How to avoid repeating
> expressions ?

You can use a function for that and use variables for the four arguments:

CREATE OR REPLACE FUNCTION f_v_same_day_overlaps(date,
       date, date, date, out overlaps bool) as
$_$
SELECT (($3 between $1 and $2) or ($4 between $1 and $2));
$_$ language sql;


Be seeing you,
--
Jorge Godoy      <jgodoy@gmail.com>

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

Предыдущее
От: Craig White
Дата:
Сообщение: Re: authentication question
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: autovacuum blues