I am trying to trigger a refresh for a materialised view after an Insert,update or delete on another materialised view. I am trying to use a triggered function to achieve this. Script is as follows;
CREATE FUNCTION aza_ods_version1.populate_fact_churn_m()
RETURNS TRIGGER AS $$
BEGIN
REFRESH MATERIALIZED VIEW aza_ods_version1.fact_churn_monthly;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER refresh_fact_churn_monthly
AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE
ON aza_ods_version1.fact_transactions
FOR EACH ROW
WHEN (OLD.* IS DISTINCT FROM NEW.*)
EXECUTE PROCEDURE aza_ods_version1.populate_fact_churn_m();
On attempting to create the trigger, I get this error; ERROR: "fact_transactions" is not a table or view SQL state: 42809
I think its because fact_transactions is a materialized view and not a view or table. Is there a way i can achieve what i am trying to??