PL/pgSQL function, recent activities integrated into SQL views