*** pgsql/doc/src/sgml/ref/do.sgml 2009/09/22 23:43:37 1.1 --- pgsql/doc/src/sgml/ref/do.sgml 2009/09/23 15:41:51 1.2 *************** *** 1,5 **** --- 1,5 ---- *************** DO codevoid. It is parsed and executed a single time. + + + The optional LANGUAGE clause can be written either + before or after the code block. + *************** DO code Examples ! Execute a simple PL/pgsql loop without needing to create a function: ! DO $$ ! DECLARE r record; BEGIN ! FOR r IN SELECT rtrim(roomno) AS roomno, comment FROM Room ORDER BY roomno LOOP ! RAISE NOTICE '%, %', r.roomno, r.comment; END LOOP; END$$; --- 96,115 ---- Examples ! Grant all privileges on all views in schema public to ! role webuser: ! DO $$DECLARE r record; BEGIN ! FOR r IN SELECT table_schema, table_name FROM information_schema.tables ! WHERE table_type = 'VIEW' AND table_schema = 'public' LOOP ! EXECUTE 'GRANT ALL ON ' || quote_ident(r.table_schema) || '.' || quote_ident(r.table_name) || ' TO webuser'; END LOOP; END$$; + This example assumes that default_do_language has its + default value, namely plpgsql.