DECLARE
   v_owner   VARCHAR (100) := 'KFM';
BEGIN
   -- ƒобавление привелегий запуска пакетов
   FOR r IN (SELECT *
               FROM ALL_OBJECTS
              WHERE owner = v_owner AND object_type IN ('PACKAGE'))
   LOOP
      EXECUTE IMMEDIATE
            'GRANT EXECUTE ON ' || v_owner || '.' || r.object_name || ' TO KFM_ROLE';
   END LOOP;

   -- ƒобавление привелегий на таблицы
   FOR r IN (SELECT *
               FROM ALL_OBJECTS
              WHERE owner = v_owner AND object_type IN ('TABLE'))
   LOOP
      EXECUTE IMMEDIATE
            'GRANT SELECT, INSERT, UPDATE, DELETE ON ' || v_owner || '.' || r.object_name || ' TO KFM_ROLE';
   END LOOP;
   
   -- ƒобавление привелегий на представлени¤
   FOR r IN (SELECT *
               FROM ALL_OBJECTS
              WHERE OWNER = v_owner AND object_type IN ('VIEW', 'MATERIALIZED VIEW'))
   LOOP
		BEGIN
		   EXECUTE IMMEDIATE
			  'GRANT SELECT ON ' || v_owner || '.' || r.object_name || ' TO KFM_ROLE';
		EXCEPTION
		   WHEN OTHERS
		   THEN
			  NULL;
		END;
   END LOOP;
END;
/
