Oracle DBMS_XDB_REPOS
Version 21c

General Information
Library Note Morgan's Library Page Header
Which has the higher priority in your organization: Deploying a new database or securing the ones you already have? Looking for a website, and resources, dedicated solely to securing Oracle databases? Check out DBSecWorx.
Purpose Operates on the Oracle XML DB Repository to create, modify and delete resources, including managing security based on access control lists (ACLs).

The interface provides both query and DML functions. Using a combination of PL/SQL packages - DBMS_XDB_REPOS, DBMS_XDBZ, and DBMS_XDB_VERSION - developers can create, delete, and rename documents and folders, move a file or folder within the folder hierarchy, set and change the access permissions on a file or folder, and initiate and manage versioning.
AUTHID CURRENT_USER
Constants
Name Data Type Value
 DELETE
DELETE_RESOURCE NUMBER 1
DELETE_RECURSIVE NUMBER 2
DELETE_FORCE NUMBER 3
DELETE_RECURSIVE_FORCE NUMBER 4
 Lock Timeout
DELETE_RES_METADATA_CASCADE NUMBER 1
DELETE_RES_METADATA_NOCASCADE NUMBER 2
 Lock Timeout
DEFAULT_LOCK_TIMEOUT PLS_INTEGER (60*60)
 Link Type
LINK_TYPE_HARD NUMBER 1
LINK_TYPE_WEAK NUMBER 2
LINK_TYPE_SYMBOLIC NUMBER 3
Dependencies
DBMS_LOB DBMS_XDB_LIB LOCKTOKENLISTTYPE
DBMS_XDB GET_XDB_TABLESPACE XMLTYPE
DBMS_XDBRESOURCE    
Documented Yes
First Available Not known
Pragmas PRAGMA SUPPLEMENTAL_LOG_DATA(default, NONE);
Security Model Owned by XDB with EXECUTE granted to PUBLIC.

Subprograms that operate on the XDB Configuration will succeed only if the current user is SYS or XDB, or the current user has the XDBADMIN or DBA role.
Source {ORACLE_HOME}/rdbms/admin/dbmsxdbr.sql
{ORACLE_HOME}/rdbms/admin/prvtxdb.sql
Subprograms
 
ACLCHECKPRIVILEGES
Checks access privileges granted by the specified ACL document dbms_xdb_repos.aclcheckprivileges(
acl_path IN VARCHAR2,
owner    IN VARCHAR2,
privs    IN public.xmlType)
RETURN PLS_INTEGER;
TBD
 
ADDRESOURCE
Given a string, inserts a new resource into the hierarchy with the string as the contents dbms_xdb_repos.addresource(
abspath IN VARCHAR2,
data    IN VARCHAR2)
RETURN NUMBER;
TBD
 
ADDTOLOCKTOKENLIST
Adds specified token to the session lock token list dbms_xdb_repos.addtolocktokenlist(token IN VARCHAR2);
TBD
 
APPENDRESOURCEMETADATA
Appends the given piece of metadata to the resource

Overload 1
dbms_xdb_repos.appendresourcemetadata(
abspath IN VARCHAR2,
data    IN sys.xmlType);
TBD
Appends the given piece of metadata identified by a REF to the resource

Overload 2
dbms_xdb_repos.appendresourcemetadata(
abspath IN     VARCHAR2,
data    IN REF sys.xmlType);
TBD
 
CHANGEOWNER
Change the owner of the resource to the given user dbms_xdb_repos.changeowner(
abspath IN VARCHAR2,
owner   IN VARCHAR2,
recurse IN BOOLEAN := FALSE);
TBD
 
CHANGEPRIVILEGES
Changes access privileges for an XDB resource dbms_xdb_repos.changeprivileges(
res_path IN VARCHAR2,
ace      IN sys.xmlType)
RETURN PLS_INTEGER;
TBD
 
CHECKPRIVILEGES
Validates access privileges granted on specified XDB resource dbms_xdb_repos.checkprivileges(
res_path IN VARCHAR2,
privs    IN sys.xmlType)
RETURN PLS_INTEGER;
TBD
 
CREATEFOLDER
Creates a folder in the Repository dbms_xdb_repos.createfolder(abspath IN VARCHAR2) RETURN BOOLEAN;
TBD
 
CREATEOIDPATH
Returns the OID-based virtual path to the resource dbms_xdb_repos.createoidpath(oid IN RAW) RETURN VARCHAR2;
TBD
 
CREATERESOURCE
Given a string, inserts a new resource into the hierarchy with the string as the contents

Overload 1
dbms_xdb_repos.createresource(
abspath   IN VARCHAR2,
data      IN VARCHAR2,
schemaurl IN VARCHAR2 := NULL,
elem      IN VARCHAR2 := NULL)
RETURN BOOLEAN;
-- sample code from $ORACLE_HOME/rdbms/admin/nacla112.sql reformatted for clarity

FUNCTION copy_host_acl(aclid raw) RETURN VARCHAR2 AS
 acl  sys.xmlType;
 path VARCHAR2(4000);
BEGIN
  acl_seq := acl_seq + 1;

  path := '/sys/acls/' || NETWORK_ACL_PREFIX ||
  TO_CHAR(acl_seq, 'fm0XXXXXXXXXXXXXXX') || '.xml';

  SELECT xmlquery('declare default element namespace
                  "http://xmlns.oracle.com/xdb/acl.xsd";
                  DECLARE namespace plsql="http://xmlns.oracle.com/plsql";
                  copy $acl := . modify delete node $acl/acl/ace/privilege/plsql:resolve
                  RETURN $acl' passing object_value returning content) INTO acl
  FROM xdb.xdb$acl
  WHERE object_id = aclid;

  IF (NOT dbms_xdb_repos.createResource(path, acl)) THEN
    RAISE program_error;
  END IF;
  RETURN path;
END;
Given an XMLTYPE and a schema URL, inserts a new resource into the hierarchy with the XMLTYPE as the contents

Overload 2
dbms_xdb_repos.createresource(
abspath   IN VARCHAR2,
data      IN sys.xmlType,
schemaurl IN VARCHAR2 := NULL,
elem      IN VARCHAR2 := NULL)
RETURN BOOLEAN;
TBD
Given a PREF to an existing XMLType row, inserts a new resource whose contents point directly at that row. The row should not already exist inside another resource

Overload 3
dbms_xdb_repos.createresource(
abspath  IN     VARCHAR2,
data     IN REF sys.xmlType,
sticky   IN     BOOLEAN := TRUE,
calcSize IN     BOOLEAN := FALSE)
RETURN BOOLEAN;
TBD
Given a CLOB, inserts a new resource into the hierarchy with the CLOB as the contents

Overload 4
dbms_xdb_repos.createresource(
abspath IN VARCHAR2,
data    IN CLOB)
RETURN BOOLEAN;
TBD
Given a BFILE, inserts a new resource into the hierarchy with the contents loaded from the BFILE

Overload 5
dbms_xdb_repos.createresource(
abspath IN VARCHAR2,
data    IN BFILE,
csid    IN NUMBER := 0)
RETURN BOOLEAN;
TBD
Given a BLOB, inserts a new resource into the hierarchy with the BLOB as the contents

Overload 6
dbms_xdb_repos.createresource(
abspath IN VARCHAR2,
data    IN BLOB,
csid    IN NUMBER := 0)
RETURN BOOLEAN;
TBD
 
DELETEFROMLOCKTOKENLIST
Deletes specified token from the session lock token list dbms_xdb_repos.deletefromlocktokenlist(token IN VARCHAR2) RETURN BOOLEAN;
TBD
 
DELETERESOURCE
Deletes a resource from the Hierarchy dbms_xdb_repos.deleteresource(
abspath       IN VARCHAR2,
delete_option IN PLS_INTEGER := DELETE_RESOURCE);
TBD
 
DELETERESOURCEMETADATA
Deletes metadata from a resource (can only be used for SB metadata)

Overload 1
dbms_xdb_repos.deleteresourcemetadata(
abspath       IN     VARCHAR2,
metadata      IN REF sys.xmlType,
delete_option IN     PLS_INTEGER := DELETE_RES_METADATA_CASCADE);
TBD
Deletes metadata from a resource (can be used for SB or NSB metadata)

Overload 2
dbms_xdb_repos.deleteresourcemetadata(
abspath       IN VARCHAR2,
metadatans    IN VARCHAR2,
metadataname  IN VARCHAR2,
delete_option IN PLS_INTEGER := DELETE_RES_METADATA_CASCADE);
TBD
 
EXISTSRESOURCE
Given a string, returns true if the resource exists in the hierarchy dbms_xdb_repos.existsresource(abspath IN VARCHAR2) RETURN BOOLEAN;
BEGIN
  IF dbms_xdb_repos.existsresource('TEST') THEN
    dbms_output.put_line('T');
  ELSE
    dbms_output.put_line('F');
  END IF;
END;
/
F

PL/SQL procedure successfully completed.
 
GETACLDOCUMENT
Gets the ACL document that protects the resource given in path dbms_xdb_repos.getacldocument(abspath IN VARCHAR2) RETURN sys.xmlType;
TBD
 
GETCONTENTBLOB
Returns the contents of the resource as a BLOB dbms_xdb_repos.getcontentblob(
abspath IN  VARCHAR2,
csid    OUT PLS_INTEGER,
locksrc IN  BOOLEAN := FALSE)
RETURN BLOB;
TBD
 
GETCONTENTCLOB
Returns the contents of the resource as a CLOB dbms_xdb_repos.getcontentclob(abspath IN VARCHAR2) RETURN CLOB;
TBD
 
GETCONTENTVARCHAR2
Returns the contents of the resource as a VARCHAR2 dbms_xdb_repos.getcontentvarchar2(abspath IN VARCHAR2) RETURN VARCHAR2;
TBD
 
GETCONTENTXMLREF
Returns the contents of the resource as a ref to an xmltype dbms_xdb_repos.getcontentxmlref(abspath IN VARCHAR2) RETURN REF sys.xmlLType;
TBD
 
GETCONTENTXMLTYPE
Returns the contents of the resource as an XMLType dbms_xdb_repos.getcontentxmltype(abspath IN VARCHAR2) RETURN sys.xmlType;
TBD
 
GETLOCKTOKEN
Gets lock token for current user for XDB resource given its path dbms_xdb_repos.getlocktoken(
abspath   IN  VARCHAR2,
locktoken OUT VARCHAR2);
TBD
 
GETLOCKTOKENLIST
Gets the session lock token list dbms_xdb_repos.getlocktokenlist RETURN xdb.LockTokenListType;
TBD
 
GETPRIVILEGES
Gets all system and user privileges granted to the current user on the given XDB resource dbms_xdb_repos.getprivileges(res_path IN VARCHAR2) RETURN sys.xmlType;
TBD
 
GETRESOID
Returns the OID of the resource, given its absolute path dbms_xdb_repos.getresoid(abspath IN VARCHAR2) RETURN RAW;
TBD
 
GETRESOURCE
Given a path in the repository, returns the XDBResource dbms_xdb_repos.getresource(abspath IN VARCHAR2) RESTURN xdb.dbms_xdbresource.xdbresource;
TBD
 
GETXDB_TABLESPACE
Returns the current tablespace of xdb, on the assumption that that is the tablespace of XDB.XDB$RESOURCE dbms_xdb_repos.getxdb_tablespace RETURN VARCHAR2;
SELECT dbms_xdb_repos.getxdb_tablespace
FROM dual;

GETXDB_TABLESPACE
------------------
SYSAUX
 
HASBLOBCONTENT
Returns true if the resource has BLOB content dbms_xdb_repos.hasblobcontent(abspath IN VARCHAR2) RETURN BOOLEAN;
TBD
 
HASCHARCONTENT
Returns true if the resource has character content dbms_xdb_repos.hascharcontent(abspath IN VARCHAR2) RETURN BOOLEAN;
TBD
 
HASXMLCONTENT
Returns true if the resource has XML content dbms_xdb_repos.hasxmlcontent(abspath IN VARCHAR2) RETURN BOOLEAN;
TBD
 
HASXMLREFERENCE
Returns true if the resource has a ref to xml content dbms_xdb_repos.hasxmlreference(abspath IN VARCHAR2) RETURN BOOLEAN;
TBD
 
ISFOLDER
Returns true is a folder dbms_xdb_repos.isfolder(abspath IN VARCHAR2) RETURN BOOLEAN;
BEGIN
  IF dbms_xdb_repos.isfolder('TEST') THEN
    dbms_output.put_line('T');
  ELSE
    dbms_output.put_line('F');
  END IF;
END;
/
BEGIN
*
ERROR at line 1:
ORA-31001: Invalid resource handle or path name "TEST"
ORA-06512: at "XDB.DBMS_XDB_REPOS", line 862
ORA-06512: at line 2
 
LINK
Creates a link from a specified folder to a specified resource dbms_xdb_repos.link(
srcpath    IN VARCHAR2,
linkfolder IN VARCHAR2,
linkname   IN VARCHAR2,
linktype   IN PLS_INTEGER := xdb.dbms_xdb.link_type_hard);
TBD
 
LOCKDISCOVERY
Gets Locks element on resource defined by abspath dbms_xdb_repos.lockdiscovery(abspath IN VARCHAR2) RETURN sys.xmlType;
TBD
 
LOCKRESOURCE (new 21c overload)
Gets a webdav-like lock for XDB resource given its path

Overload 1
dbms_xdb_repos.lockresource(
abspath   IN VARCHAR2,
depthzero IN BOOLEAN,
shared    IN BOOLEAN)
RETURN BOOLEAN;
TBD
Gets a webdav-like lock for XDB resource given its path

Overload 2
dbms_xdb_repos.lockresource(
abspath   IN  VARCHAR2,
depthzero IN  BOOLEAN,
shared    IN  BOOLEAN,
token     OUT VARCHAR2,
timeout   IN  PLS_INTEGER := DEFAULT_LOCK_TIMEOUT)
RETURN BOOLEAN;
TBD
 
PROCESSLINKS
Process document links in the specified resource, looking at the current resource configuration parameters dbms_xdb_repos.processlinks(
abspath IN VARCHAR2,
recurse IN BOOLEAN := FALSE );
TBD
 
PURGERESOURCEMETADATA
Deletes all user metadata from a resource SB metadata is removed in cascade mode i.e. the rows are deleted from the corresponding metadata tables dbms_xdb_repos.purgeresourcemetadata(abspath IN VARCHAR2);
TBD
 
REFRESHCONTENTSIZE
Recompute the content size of the specified resource dbms_xdb_repos.refreshcontentsize(
abspath IN VARCHAR2,
recurse IN BOOLEAN := FALSE);
TBD
 
REFRESHLOCK
Refreshes a webdav-like lock for XDB resource given its path dbms_xdb_repos.refreshlock(
abspath    IN VARCHAR2,
token      IN VARCHAR2,
newTimeout IN PLS_INTEGER := DEFAULT_LOCK_TIMEOUT);
TBD
 
RENAMERESOURCE
Renames a XDB resource dbms_xdb_repos.renameresource(
srcpath    IN VARCHAR2,
destfolder IN VARCHAR2,
newname    IN VARCHAR2);
TBD
 
SETACL
Sets the ACL for an XDB resource to that specified in the ACL path dbms_xdb_repos.setacl(
res_path IN VARCHAR2,
acl_path IN VARCHAR2);
TBD
 
TOUCHRESOURCE
Change the last mod time of the resource to the current time dbms_xdb_repos.touchresource(abspath IN VARCHAR2);
exec dbms_xdb_repos.touchresource('TEST');
BEGIN dbms_xdb_repos.touchresource('TEST'); END;
*
ERROR at line 1:
ORA-31001: Invalid resource handle or path name "TEST"
ORA-06512: at "XDB.DBMS_XDB_REPOS", line 878
ORA-06512: at line 1
 
UNLOCKRESOURCE
Removes lock for XDB resource given lock token dbms_xdb_repos.unlockresource(
abspath  IN VARCHAR2,
deltoken IN VARCHAR2 := NULL)
RETURN BOOLEAN;
TBD
 
UPDATERESOURCEMETADATA
Updates metadata for a resource (can be used to update SB metadata only). The new metadata must be SB

Overload 1
dbms_xdb_repos.updateresourcemetadata(
abspath     IN     VARCHAR2,
oldmetadata IN REF sys.xmlType,
newmetadata IN REF sys.xmlType);
TBD
Updates metadata for a resource (can be used to update SB metadata only). The new metadata can be either SB or NSB

Overload 2
dbms_xdb_repos.updateresourcemetadata(
abspath     IN     VARCHAR2,
oldmetadata IN REF sys.xmlType,
newmetadata IN     sys.xmlType);
TBD
Updates metadata for a resource - can be used for both SB or NSB metadata

Overload 3
dbms_xdb_repos.updateresourcemetadata(
abspath     IN VARCHAR2,
oldns       IN VARCHAR2,
oldname     IN VARCHAR,
newmetadata IN sys.xmlType);
TBD
Updates metadata for a resource - can be used for both SB or NSB metadata. New metadata must be SB

Overload 4
dbms_xdb_repos.updateresourcemetadata(
abspath     IN     VARCHAR2,
oldns       IN     VARCHAR2,
oldname     IN     VARCHAR,
newmetadata IN REF sys.xmlType);
TBD

Related Topics
Built-in Functions
Built-in Packages
Database Security
What's New In 19c
What's New In 20c-21c

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2022 Daniel A. Morgan All Rights Reserved
  DBSecWorx