set echo on
set define off
set line 120

--conn rss/rss

-- Create an XML DB repository resource of the normalized RSS 2.0 feed
declare
  cursor getNewsItems is
    select object_value
    from newsItemsRSSView n;
  res boolean;
  targetFolder varchar2(1024) :=  '/home/RSS';
  oid integer := 2008;
begin
  if dbms_xdb.existsResource(targetFolder) then
     dbms_xdb.deleteResource(targetFolder,dbms_xdb.DELETE_RECURSIVE_FORCE);
     commit;
  end if;
  res := dbms_xdb.createFolder(targetFolder);
  for newsItem in getNewsItems loop
    res := DBMS_XDB.createResource(targetFolder || '/' || 'news' || oid || '.xml', newsItem.object_value);
  end loop;
end;
/
commit
/



