Subject Custom RI was Re: Possible bug with CHECK constraint
Author promolinux
--- In, Helen Borrie <helebor@t...>
> At 09:20 PM 3/10/2004 -0300, you wrote:
> It is also wrong. Assuming this is a BeforeDelete trigger on
BOMBAS, your
> trigger will all deletions to any records from this table if *any*
> in despachado has a matching record in bombas..

Is strange, but dont do that. If i select a record in BOMBAS not
having IDBOMBAS value in DESPACHADO it delete,but if i select one
having a value in despachado it raises exception.

> What you *really* want to do is test whether there are any records
> despachado that are dependent on the CURRENT record:
> create trigger bd_bombas for bombas
> active before delete
> as
> begin
> if (exists (select 1 from despachado
> where idbomba = OLD.idbomba)) then
> exception ex_despachado_bomba;
> end

I will try that.

> Hint: you will also need Before Insert and Before Update triggers
> DESPACHADO to restrict despachado.idbomba to values that exist in

Uf, a lot of stuff... I really like foreign keys.