Board index » delphi » Help with before update trigger

Help with before update trigger

I have a table in which many other tables could have a foreign key refering to
it.  One of the columns within this table is not allowed to be modified if
there is any foreign key refering to the row.  How would I check for this in
the before update trigger?
 

Re:Help with before update trigger


Quote
daveb wrote:
> I have a table in which many other tables could have a foreign key refering to
> it.  One of the columns within this table is not allowed to be modified if
> there is any foreign key refering to the row.  How would I check for this in
> the before update trigger?

  You can hard include in your trigger sequence of

    Select Count(*) from REFERENCES_TABLE
     Where <foreign key columns = this table primary key columns>
    Into :Buffer;
    If (Buffer>0) then Exception <Your own exception>;

  You can even determine within  your SP what are this tables and what are needed
columns, but cannot dynamically construct with this info select statements. It is
possible from application only.

Other Threads