aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_tr_rate_plan_update_parent
Parameters
Name
Type
Mode
Definition
BEGIN IF (new.link_plan_id is not null) THEN update rate_plan rp set has_active_child = exists(select 1 from rate_plan link where link.enabled and link.link_plan_id = new.link_plan_id) where rp.id = new.link_plan_id; END IF; IF (TG_OP = 'UPDATE') and (old.link_plan_id is not null) and (old.link_plan_id is distinct from new.link_plan_id) THEN update rate_plan rp set has_active_child = exists(select 1 from rate_plan link where link.enabled and link.link_plan_id = old.link_plan_id) where rp.id = old.link_plan_id; END IF; RETURN NULL; end