Subject Re: [firebird-support] Re: Checking periods don't overlap
Author Ivan Prenosil
> > 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

Since you said "if", does it mean it will not work in other transactions modes ?
If that is the case, than it is just hack, because consistency of the database
depends on application (whether it uses correct tr. mode or not).
But if you consider it as a "solution" or that this "works correctly",
you can achieve the same with "read committed no record versions" mode
in Firebird, it will also freeze when comming to uncommitted record.

Ivan

> 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.