Sponsored Links
PHP Oracle Tutorials
- PHP Oracle Web Development
- XML Processing in PHP and Oracle Applications
- Creating XML with the DOM PHP Extension
- Querying a DOM Document with XPath
- Transforming and Processing XML with XSLT
- Performing XML Processing inside the Database
- Moving All the XML Processing into the Database
- Performing XSLT Transformations inside the Database
- Using Oracle Database for Storing, Modifying, and Retrieving XML Data
- Using XMLType for Handling XML Data in the Database
- Using XML Schemas
- Retrieving XML Data
- Using XMLType Views
- Performing DML Operations on XML Schema Based XMLType Views
- Using Oracle XML DB Repository
- Accessing Repository Resources with SQL
- Taking Advantage of Standard Internet Protocols
- Querying Data with Oracle XQuery
- Breaking up XML into Relational Data
Tutorials
PHP OracleAccessing Repository Resources with SQL
Accessing Repository Resources with SQL
In fact, Oracle XML DB repository resources are stored in a set of database tables and indexes, which can be accessed via SQL. You are not supposed to access those tables directly. Instead, Oracle XML DB provides two public views RESOURCE_VIEW and PATH_VIEW through which you can access repository resources.
For example, you might issue the following query against the RESOURCE_VIEW view to access the employee XML document stored in the XML repository as /public/xmlusr/emps/emp303.xml, assuming that you have executed the PL/SQL block shown in the preceding section.
- SELECT extract(r.RES, '/Resource/Contents/*').getStringVal()
- RESULT FROM RESOURCE_VIEW r
- WHERE equals_path(res, '/public/xmlusr/emps/emp303.xml') = 1;
This should produce the following result:
- <EMPLOYEE
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" target="_blank" rel="nofollow"
- xsi:noNamespaceSchemaLocation="employee.xsd"
- id="303">
- <ENAME>Locke</ENAME>
- <SALARY>7000</SALARY>
- </EMPLOYEE>
However, in this particular example you don't have to query RESOURCE_VIEW to retrieve the above XML document through SQL. Instead, you might issue the following query against the employees XMLType table:
- SELECT extract(OBJECT_VALUE,'/').getStringVal()
- RESULT FROM employees
- WHERE existsNode(OBJECT_VALUE, '/EMPLOYEE/@id="303"') = 1;
You might be asking yourself: How could that have happened?a document uploaded into the XML repository appeared in an XMLType table? As you might recall from the listing describing the employee.xsd XML schema registration in the
Using XML Schemas section, the employees XMLType table is specifi ed as a default table in the employee.xsd XML schema and so it must have been generated during the schema registration process. Since the employee XML document inserted into the XML repository by the PL/SQL code as discussed in the preceding section is based on the employee.xsd XML schema, this document has been automatically inserted into the employees XMLType table.
Comments
Sponsored Links
