maya
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
part_trig_func_alert()
Parameters
Name
Type
Mode
Definition
/* v20150416 RRB To redirect inserts pointing to parent table (alert) to the right child table (alert_p*) */ DECLARE table_name varchar; BEGIN table_name := (select 'alert_p'|| to_char(NEW.creationdate,'IYYY')||'w'||to_char(NEW.creationdate,'IW') as iso_year_week); /* TODO: check if the table exists and if not, create it */ PERFORM 1 FROM pg_tables WHERE schemaname = 'public' AND tablename = table_name; IF NOT FOUND THEN PERFORM public.ot_rw_createchildpart_alert(NEW.creationdate::date); END IF; EXECUTE 'INSERT INTO public.'||table_name||' SELECT $1.*' USING NEW; RETURN NULL; EXCEPTION WHEN OTHERS THEN RAISE WARNING '%,%', SQLSTATE, SQLERRM; RETURN NEW; END