Exforsys.com
 
Home Tutorials PHP Oracle
 

Accessing 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.


Sample Code
  1. SELECT extract(r.RES, '/Resource/Contents/*').getStringVal()
  2. RESULT FROM RESOURCE_VIEW r
  3. WHERE equals_path(res, '/public/xmlusr/emps/emp303.xml') = 1;
  4.  
Copyright exforsys.com


This should produce the following result:


Sample Code
  1.  
  2. <EMPLOYEE
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" target="_blank" rel="nofollow"
  4. xsi:noNamespaceSchemaLocation="employee.xsd"
  5. id="303">
  6. <ENAME>Locke</ENAME>
  7. <SALARY>7000</SALARY>
  8. </EMPLOYEE>
Copyright exforsys.com


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:


Sample Code
  1. SELECT extract(OBJECT_VALUE,'/').getStringVal()
  2. RESULT FROM employees
  3. WHERE existsNode(OBJECT_VALUE, '/EMPLOYEE/@id="303"') = 1;
  4.  
Copyright exforsys.com


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.



Read Next: Taking Advantage of Standard Internet Protocols



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape