/* initialize _old and _new with dummy values for INSERT and UPDATE events*/
_old := row((select 1));
_new := row((select 1));
END IF;
_data := json_build_object(
'old', {{OLD_PAYLOAD_EXPRESSION}},
'new', {{NEW_PAYLOAD_EXPRESSION}}
);
IF (TG_OP <> 'UPDATE') OR (_old <> _new) THEN
PERFORM hdb_catalog.insert_event_log(CAST(TG_TABLE_SCHEMA AS text), CAST(TG_TABLE_NAME AS text), CAST('{{NAME}}' AS text), TG_OP, _data);
END IF;
RETURN NULL;
END;
$$;
DROP TRIGGER IF EXISTS {{QUALIFIED_TRIGGER_NAME}} ON {{QUALIFIED_TABLE}};
CREATE TRIGGER {{QUALIFIED_TRIGGER_NAME}} AFTER {{OPERATION}} ON {{QUALIFIED_TABLE}} FOR EACH ROW EXECUTE PROCEDURE hdb_views.{{QUALIFIED_TRIGGER_NAME}}();