we have a sample PL/PgSQL function (dating from at least 7.2) demonstrating query result loops, which refreshes some pseudo materialized views stored in a user-defined table.
As we've had proper materialized views since 9.3, I thought it might be nice to update this with a self-contained sample which can be used as-is; see attached patch.
(As a side note the current sample function contains a couple of "%s" placeholders which should be just "%"; a quick search of plpgsql.sgml shows this is the only place they occur).