esus
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
taa_atend
Parameters
Name
Type
Mode
Definition
begin if (tg_op = 'INSERT') then update tb_ator_papel set qt_referencia = (qt_referencia + 1) where co_seq_ator_papel = new.co_lotacao; elsif (tg_op = 'UPDATE') then if ( old.co_lotacao is null) and (new.co_lotacao is not null) then update tb_ator_papel set qt_referencia = (qt_referencia + 1) where co_seq_ator_papel = new.co_lotacao; elsif (old.co_lotacao is not null) and (new.co_lotacao is null) then update tb_ator_papel set qt_referencia = (qt_referencia - 1) where co_seq_ator_papel = old.co_lotacao; elsif (old.co_lotacao != new.co_lotacao) then update tb_ator_papel set qt_referencia = (qt_referencia + 1) where co_seq_ator_papel = new.co_lotacao; update tb_ator_papel set qt_referencia = (qt_referencia - 1) where co_seq_ator_papel = old.co_lotacao; end if; elsif (tg_op = 'DELETE') then update tb_ator_papel set qt_referencia = (qt_referencia - 1) where co_seq_ator_papel = old.co_lotacao; end if; return NULL; end;