aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_tr_followup_counter
Parameters
Name
Type
Mode
Definition
DECLARE v_ref_type t_ref_type; v_ref_id int; BEGIN v_ref_type = CASE TG_OP WHEN 'DELETE' THEN OLD.ref_type ELSE NEW.ref_type END; v_ref_id = CASE TG_OP WHEN 'DELETE' THEN OLD.ref_id ELSE NEW.ref_id END; IF v_ref_type = 'booking' THEN UPDATE booking SET flag_count = (SELECT count(*) FROM followup WHERE ref_type = v_ref_type AND ref_id = v_ref_id) WHERE id = v_ref_id; ELSIF v_ref_type = 'register' THEN UPDATE registration SET flag_count = (SELECT count(*) FROM followup WHERE ref_type = v_ref_type AND ref_id = v_ref_id) WHERE id = v_ref_id; END IF; RETURN NULL; END