How to Create an Instance of XDBUriType

XDBUriType is automatically registered with UriFactory so that an XDBUriType instance can be generated by providing the URI to the getURI method.

Currently, XDBUriType is the default UriType generated by the UriFactory.getUri method, when the URI does not have any of the recognized prefixes, such as "http://","/DBURI", or "/ORADB".

All DBUriType URIs should have a prefix of either /DBURI or /ORADB, case insensitive.

Example 12-10 Returning XDBUriType Instance

For example, the following statement returns an XDBUriType instance that refers to /home/scott/docl.xml:

SELECT sys.UriFactory.getUri('/home/scott/doc1.xml') FROM dual;

Example 12-11 Creating XDBUriType, Inserting Values Into a Purchase Order Table and Selecting All the PurchaseOrders

The following is an example of how XDBUriType is used:

CREATE TABLE uri_tab

poUrl SYS.UriType, -- Note that we have created an abstract type column --so that any type of URI can be used poName VARCHAR2(1000)

-- insert an absolute url into poUrl

-- the factory will create an XDBUriType since there's no prefix

INSERT INTO uri_tab VALUES

(UriFactory.getUri('/public/orders/po1.xml')/ 'SomePurchaseOrder');

-- Now get all the purchase orders

SELECT e.poUrl.getClob(), poName FROM uri_tab e;

-- Using PL/SQL, you can access table uri_tab as follows: declare a UriType; begin

-- Get the absolute URL for purchase order named like 'Some%' SELECT poUrl into a from uri_tab WHERE poName like 'Some%'; printDataOut(a.getClob()); end;

Example 12-12 Retrieving Purchase Orders at a URL Using UriType, getXML() and extractValue()

Since getXML() returns an XMLType, it can be used in the EXTRACT family of operators. For example:

SELECT e.poUrl.getClob() FROM uri_tab e

WHERE extractValue(e.poUrl.getXML(),'/User') = 'SCOTT';

This statement retrieves all Purchase Orders for user SCOTT.

0 0

Post a comment

  • Receive news updates via email from this site