DROP FUNCTION IF EXISTS func_refresh_each_view_materialized();

CREATE OR REPLACE FUNCTION func_refresh_each_view_materialized()
RETURNS table (resul text, vista text) AS $$
BEGIN
    BEGIN
		
		RETURN QUERY select func_refresh_view_materialized(vname), vname from (
			select unnest(Array[
			'entrega_resultados_view_m','asignacion_cita_view_m','confirmacion_cita_view_m']) as vname
			) as x;			
		
	EXCEPTION WHEN OTHERS THEN
		RAISE EXCEPTION 'Error al intentar refrescar las vistas.  :( ';	
    END;

END;
$$ LANGUAGE plpgsql;