Storing your Scripts in the XMLDB Repository

The underlying structure of the XMLDB repository is a blob, but why not…? The following code was once demonstrated by Mark Drake in May on the OTN XMLDB Forum. It is a very useful alternative way to store some of our code / scripts…

DECLARE
  res BOOLEAN;
BEGIN
  res := dbms_xdb.createResource('/public/q1.xqy','My Xquery');
  commit;
END;
/ 
SELECT xmlquery(xdburitype('/public/q1.xqy').getClob() 
       passing OBJECT_VALUE 
       returning content) 
FROM   MY_XML_TABLE
/

Fill in “My XQuery” or else, with your code or statements. Secure it via XMLDB’s ACL security options and “voila” your own script repository, amongst others, maintainable via WebDAV.