Re: Best way to prevent overlapping dates

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: Best way to prevent overlapping dates
Дата
Msg-id F6BA8F44-EE0D-4007-96C5-8B5A3D98CA00@seespotcode.net
обсуждение исходный текст
Ответ на Best way to prevent overlapping dates  ("Andrus" <kobruleht2@hot.ee>)
Ответы Re: Best way to prevent overlapping dates  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-general
On May 25, 2007, at 3:22 , Andrus wrote:

> CREATE TRIGGER puhkus_sequenced_trigger BEFORE INSERT OR UPDATE ON
> puhkus
>    FOR EACH ROW EXECUTE PROCEDURE puhkus_sequenced_pkey();

You can also use CREATE CONSTRAINT TRIGGER, which allows you to have
deferrable constraints. This is useful if statements within a
transaction may temporarily put the database in a state where it
violates the constraint: the constraint will be called at the end of
the transaction to make sure integrity is maintained.

http://www.postgresql.org/docs/8.2/interactive/sql-createconstraint.html

> create table puhkus (palgus date, plopp date);
>
> alter table puhkus add check
> (NOT EXISTS ( SELECT *
> FROM puhkus AS I1
> WHERE 1 < (SELECT COUNT(*)
> FROM puhkus AS I2
> WHERE doverlaps(i1.palgus, i1.plopp, i2.palgus, i2.plopp)
> ) ));
>
> but got error
>
> ERROR: cannot use subquery in check constraint

Right. As the error says, subqueries in CHECK constraints is not
implemented in PostgreSQL.


Michael Glaesemann
grzm seespotcode net



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

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: Re: Languages and Functions
Следующее
От: "Greg Sabino Mullane"
Дата:
Сообщение: Re: feature suggestions