Re: Why overlaps is not working

From: Jorge Godoy <jgodoy(at)gmail(dot)com>
To: "Andrus" <eetasoft(at)online(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why overlaps is not working
Date: 2006-11-09 20:50:37
Message-ID: 8764dos5sy.fsf@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Andrus" <eetasoft(at)online(dot)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(at)gmail(dot)com>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message sumit kumar 2006-11-09 20:59:31 LIKE OPERATOR cardinality estimation
Previous Message Craig White 2006-11-09 20:07:37 Re: authentication question