Oracle9i XML Database Developer's Guide - Oracle XML DB Release 2 (9.2) Part Number A96620-02 |
|
|
View PDF |
This chapter describes the Oracle XML DB Resource API for PL/SQL (DBMS_XDB
) used for accessing and managing Oracle XML DB Repository resources and data using PL/SQL. It includes methods for managing the resource security and Oracle XML DB configuration.
It contains the following sections:
This chapter describes the Oracle XML DB Resource API for PL/SQL (PL/SQL package DBMS_XDB
). This is also known as the PL/SQL foldering API.
Oracle XML DB Repository is modeled on XML and provides a database file system for any data. Oracle XML DB Repository maps path names (or URLs) onto database objects of XMLType
and provides management facilities for these objects.
DBMS_XDB
package provides functions and procedures for accessing and managing Oracle XML DB Repository using PL/SQL.
The DBMS_XDB
provides the PL/SQL application developer with an API that manages:
Table 16-1 lists the DBMS_XDB
Oracle XML DB resource management methods.
Figure 16-1 describes the calling sequence when using DBMS_XDB
to manage Repository resources:
createResource()
or create folders using createFolder()
See Example 16-1 for an examples of using DBMS_XDB
to manage Repository resources.
DECLARE retb boolean; BEGIN retb := dbms_xdb.createfolder('/public/mydocs'); commit; END; / declare bret boolean; begin bret := dbms_xdb.createresource('/public/mydocs/emp_scott.xml','<emp_name>scott</emp_nam e>'); commit; end; / declare bret boolean; begin bret := dbms_xdb.createresource('/public/mydocs/emp_david.xml','<emp_name>david</emp_nam e>'); commit; end; / call dbms_xdb.link('/public/mydocs/emp_scott.xml','/public/mydocs', 'person_scott.xml'); call dbms_xdb.link('/public/mydocs/emp_david.xml','/public/mydocs', 'person_david.xml'); commit; call dbms_xdb.deleteresource('/public/mydocs/emp_scott.xml'); call dbms_xdb.deleteresource('/public/mydocs/person_scott.xml'); call dbms_xdb.deleteresource('/public/mydocs/emp_david.xml'); call dbms_xdb.deleteresource('/public/mydocs/person_david.xml'); call dbms_xdb.deleteresource('/public/mydocs'); commit;
Table 16-2 lists the DBMS_XDB
Oracle XML DB ACL- based security management methods. Because the arguments and return values for the methods are self-explanatory, only a brief description of the methods is provided here.
Figure 16-2 describes the calling sequence when using DBMS_XDB
to manage security.
DBMS_XDB
security management method take in a path (resource_path, abspath, or acl_path).DBMS_XDB
methods listed in Table 16-2 to perform security management tasks:
See Example 16-2 for an examples of using DBMS_XDB
to manage Repository resource security.
DECLARE retb boolean; BEGIN retb := dbms_xdb.createfolder('/public/mydocs'); commit; END; / declare bret boolean; begin bret := dbms_xdb.createresource('/public/mydocs/emp_scott.xml','<emp_name>scott</emp_nam e>'); commit; end; / call dbms_xdb.setacl('/public/mydocs/emp_scott.xml', '/sys/acls/all_owner_acl.xml'); commit; select dbms_xdb.getacldocument('/public/mydocs/emp_scott.xml') from dual; declare r pls_integer; ace xmltype; ace_data varchar2(2000); begin ace_data := '<ace xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"> <principal>SCOTT</principal> <grant>true</grant> <privilege> <all/> </privilege> </ace>'; ace := xmltype.createxml(ace_data); r := dbms_xdb.changeprivileges('/public/mydocs/emp_scott.xml', ace); dbms_output.put_line('retval = ' || r); commit; end; / select dbms_xdb.getacldocument('/public/mydocs/emp_scott.xml') from dual; select dbms_xdb.getprivileges('/public/mydocs/emp_scott.xml') from dual; call dbms_xdb.deleteresource('/public/mydocs/emp_scott.xml'); call dbms_xdb.deleteresource('/public/mydocs'); commit;
Table 16-3 lists the DBMS_XDB
Oracle XML DB Configuration Management Methods. Because the arguments and return values for the methods are self-explanatory, only a brief description of the methods is provided here.
DBMS_XDB Method | Arguments, Return Value |
---|---|
CFG_get |
Return value: |
CFG_refresh |
Return value: N/A |
CFG_update |
Argument: (xdbconfig IN Return value: N/A |
Figure 16-3 shows the calling sequence when using DBMS_XDB
for configuration management.
The diagram shows the following sequence:
See Example 16-3 for an example of using DBMS_XDB
for configuration management of Repository resources.
connect system/manager select dbms_xdb.cfg_get() from dual; declare config xmltype; begin config := dbms_xdb.cfg_get(); -- Modify the xdb configuration using updatexml, etc ... dbms_xdb.cfg_update(config); end; / -- To pick up the latest XDB Configuration -- In this example it is not needed as cfg_update(), -- automatically does a cfg_refresh(). call dbms_xdb.cfg_refresh();
Table 16-4 lists the DBMS_XDB
Oracle XML DB hierarchical index rebuild methods. Because the arguments and return values for the methods are self-explanatory, only a brief description of the methods is provided here.
DBMS_XDB Method | Arguments, Return Values |
---|---|
RebuildHierarchicalIndex |
Return value: N/A |
Figure 16-4 shows the calling sequence when using DBMS_XDB
for rebuilding hierarchical indexes. To rebuild the hierarchical indexes, first delete the entries from xdb.xdb$h_index
and rebuild the hierarchical index by executing DBMS_XDB.RebuildHierachicalIndex
. Example 16-4 shows how to use DBMS_XDB
to rebuild the Repository hierarchical indexes.
connect system/manager delete from xdb.xdb$h_index; commit; execute dbms_xdb.RebuildHierarchicalIndex;