create or replace function f_population_check() returns bigint as ' declare v_tot bigint; v_query varchar(4000); v_count integer; r record; begin v_tot:= 0; for r in select * from pg_tables loop v_count:= 0;
v_query := ''select count(*) from '' || r.tablename; v_count:= EXECUTE v_query; if v_count = 0 then RAISE NOTICE ''Empty table % '',r.tablename; end if; v_tot:= v_tot + 1; end loop; return v_tot; end; ' language 'plpgsql';