esus
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
taa_agendado
Parameters
Name
Type
Mode
Definition
begin if (tg_op = 'INSERT') then if (new.co_prontuario is not null) then update tb_prontuario set qt_referencia = (qt_referencia + 1) where co_seq_prontuario = new.co_prontuario; end if; if (new.co_origem is not null) then update tb_ad_cidadao set qt_referencia = (qt_referencia + 1) where co_prontuario = new.co_prontuario; end if; elsif (tg_op = 'DELETE') then if (old.co_prontuario is not null) then update tb_prontuario set qt_referencia = (qt_referencia - 1) where co_seq_prontuario = old.co_prontuario; end if; if (old.co_origem is not null) then update tb_ad_cidadao set qt_referencia = (qt_referencia - 1) where co_prontuario = old.co_prontuario; end if; end if; return NULL; end;