Subject | Re: [firebird-support] Prevent overlaping dates in concurent environment |
---|---|
Author | Tomasz Tyrakowski |
Post date | 2018-09-12T14:48:02Z |
On 12.09.2018 at 15:04, Svein Erling Tysvær setysvar@...
[firebird-support] wrote:
insert all dates from within the interval (and not just the boundaries),
sorry for that.
However, when you swap dates to timestamps (date + time) or just the
intervals of real numbers, the whole idea breaks apart.
Nonetheless, the problem itself doesn't seem very artificial (I can
imagine many situations when this kind of constraint would be useful)
and it would be strange if there was no systematic solution.
In fact what is needed here is a check that gets executed on commit ;)
cheers
Tomasz
--
__--==============================--__
__--== Tomasz Tyrakowski ==--__
__--== SOL-SYSTEM ==--__
__--== http://www.sol-system.pl ==--__
__--==============================--__
[firebird-support] wrote:
> Why wouldn't my suggestion work, Tomasz? When Karol inserts his first rowYes, I've already admitted I didn't get the idea that you wanted to
> into his main table it will contain DATE_FROM 2018-09-10 and DATE_TO
> 2018-09-20 and the trigger would insert 11 rows (one for each date) into my
> suggested table. When the next row is inserted with DATE_FROM 2018-09-15
> and DATE_TO 2018-09-22, the trigger would fail inserting 8 rows due to the
> unique constraint.
>
> The one place where I know my suggestion was incorrect, is that the trigger
> needs to be AFTER UPDATE as well (I only said AFTER INSERT/DELETE), with a
> change of dates, both DELETE and INSERT must be done. Other than that I
> would expect it to work (although it does make things a bit slower than not
> having this additional table).
>
> Set
insert all dates from within the interval (and not just the boundaries),
sorry for that.
However, when you swap dates to timestamps (date + time) or just the
intervals of real numbers, the whole idea breaks apart.
Nonetheless, the problem itself doesn't seem very artificial (I can
imagine many situations when this kind of constraint would be useful)
and it would be strange if there was no systematic solution.
In fact what is needed here is a check that gets executed on commit ;)
cheers
Tomasz
--
__--==============================--__
__--== Tomasz Tyrakowski ==--__
__--== SOL-SYSTEM ==--__
__--== http://www.sol-system.pl ==--__
__--==============================--__