aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_trg_masterfile_before_update
Parameters
Name
Type
Mode
Definition
DECLARE target_id INT; msg_code text = '81003'; msg jsonb = $${ "81003": "Cannot delete, %s is being used as system parameter.", "81004": "Cannot disabled, %s is being used as system parameter.", "81005": "Cannot delete, %s is being used in one or more channels.", "81006": "Cannot disabled, %s is being used in one or more channels." }$$; begin IF (TG_OP = 'DELETE') or (old.enabled and not new.enabled) THEN msg_code := IIF(TG_OP = 'DELETE', '81003', '81004'); IF TG_TABLE_NAME = 'title' THEN if (old.id = fn_sys_param('DEFAULT', 'TITLE', -1)) or (old.id = fn_sys_param('DEFAULT', 'TITLE_MALE', -1)) or (old.id = fn_sys_param('DEFAULT', 'TITLE_FEMALE', -1)) then raise exception '%', sys_msg_format(msg_code, msg->>msg_code, old.name); end if; ELSIF (OLD.ID = FN_SYS_PARAM('DEFAULT', UPPER(TG_TABLE_NAME), -1)) THEN -- ORIGIN, VIP, NATIONALITY, FOLIO_PATTERN, RESERVATION_TYPE raise exception '%', sys_msg_format(msg_code, msg->>msg_code, old.name); END IF; IF ((TG_TABLE_NAME = 'origin') and exists(select id from channel cn where cn.origin_id = old.id)) OR ((TG_TABLE_NAME = 'folio_pattern') and exists(select id from channel cn where cn.folpat_id = old.id)) THEN msg_code := IIF(TG_OP = 'DELETE', '81005', '81006'); raise exception '%', sys_msg_format(msg_code, msg->>msg_code, old.name); END IF; END IF; return new; END;