Subject Re: Checking periods don't overlap
Author johnsparrowuk
--- In firebird-support@yahoogroups.com, "Ivan Prenosil"
<Ivan.Prenosil@s...> wrote:
> Do you think the problem lies in multi-versioning ?

I think if you guys can't make this work properly then it's a
weakness, yes.

> Tell me how would you ensure the field value is unique without using
> unique index/constraint in M$ ?

In a trigger:

if exists(select t.pk from inserted i inner join MyTable t on
i.uniqueval = t.uniqueval and i.pk <> t.pk)
begin
raiserror('Dup value(s)',16,1)
rollback transaction
return
end

If you run this in a Read Committed transaction (default behaviour)
it would stop and freeze when it came to an uncommitted record. It
would either timeout (if you set the system up that way), or when
rollback / commit occured in the other transaction it would proceed
(with or without the conflicting value).

Of course M$ does support unique constraints without an index, so
this example is a little contrived.

> Or how would you implement your overlap constraint in M$ ?

Same idea. Should I post the code?

John