Subject Re: [firebird-support] Triggers and referential integrity
Author Martijn Tonies
Hi Tim,

> :-) I already make extensive use of domains with check constraints - the
> primary table has every field except the primary key field as a domain
with
> a check constraint.
>
> As I said, the problem isn't the Inserts so much as the deletes. In the
> case of a tax table (we also have three here), how do I prevent the user
> from deleting a tax type if there are any records in the primary table
with
> that tax type?

In a BEFORE DELETE trigger, check to see if there are any rows - in all
child tables!! - with that particular value. Raise an EXCEPTION and the
DELETE will be aborted.


With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird & MS SQL Server.
Upscene Productions
http://www.upscene.com