PlPgsql function which returns result set of database
===

everybody, i have problem with PL/PGSQL with functions. 
Basically, I have a query such:

   SELECT 
  nspname AS schemaname,relname,reltuples
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE 
  nspname NOT IN ('pg_catalog', 'information_schema') AND
  relkind='r' and nspname='1' 
ORDER BY relname;

this, query, derives database statistics of opened rows in tables. But our dabase has a huge number of schemes.So, I have to write function which iterates over all schemes with that query, getting number of rows opened in tables in each scheme. I have tried to google the problem but, I couldn't find any related example. Thanks to everybody for the help.