Académique Documents
Professionnel Documents
Culture Documents
1. 2. 3.
VARCHAR2 unstructured, limited size CLOBs unstructured, max file = 2GB XMLType structured, associate with XDK and other XML operations
XML DB Architecture:
1. 2.
3.
Using XMLTYPE
XML Piecewise Update
Update part of the xml document in the database specified by the XPath expression.
Manually or automatically validate XML documents as they are inserted to the Database.
create table profile of XMLType XMLSCHEMA http://bumbus.ucdavis.edu/scholar.xsd ELEMENT UCLEADS Declares XMLType Table conformed to an XML Schema and specific the root element of the xml document to be inserted.
Values are extracted from the nodes of the XMLType table generated using the XMLSequence()
SELECT existsNode(x.pfile, '/UCLEADS/ScholarProfile/Major') SubFound, existsNode(x.pfile, '/UCLEADS/ScholarProfile[Major="ORACLE"]') MajorFound, existsNode(x.pfile, '/UCLEADS/ScholarProfile[Major="Oracle"]') MajorFound2 FROM Profile1 X;
<EMPLOYEES> <EMP> <EMPNO>112</EMPNO> <EMPNAME>Joe</EMPNAME> <SALARY>50000</SALARY> </EMP> <EMP> <EMPNO>217</EMPNO> <EMPNAME>Jane</EMPNAME> <SALARY>60000</SALARY> </EMP> <EMP> <EMPNO>412</EMPNO> <EMPNAME>Jack</EMPNAME> <SALARY>40000</SALARY> </EMP> </EMPLOYEES>
UPDATEXML takes as arguments an XMLType instance and an XPath-value pair and returns an XMLType instance with the updated value
SELECT UPDATEXML(emp_col, '/EMPLOYEES/EMP[EMPNAME="Joe"]/SALARY/text()', 100000, '//EMP[EMPNAME="Jack"]/EMPNAME/text()','Jackson', '//EMP[EMPNO=217]', XMLTYPE.CREATEXML('<EMP><EMPNO>217</EMPNO><EMPNAME>Jane< /EMPNAME>')) FROM emp_tab e;
<EMPLOYEES> <EMP> <EMPNO>112</EMPNO> <EMPNAME>Joe</EMPNAME> <SALARY>50000</SALARY> </EMP> <EMP> <EMPNO>217</EMPNO> <EMPNAME>Jane</EMPNAME> <SALARY>60000</SALARY> </EMP> <EMP> <EMPNO>412</EMPNO> <EMPNAME>Jack</EMPNAME> <SALARY>40000</SALARY> </EMP> </EMPLOYEES>
<EMPLOYEES> <EMP> <EMPNO>112</EMPNO> <EMPNAME>Joe</EMPNAME> <SALARY>100000</SALARY> </EMP> <EMP> <EMPNO>217</EMPNO> <EMPNAME>Jane</EMPNAME> </EMP> <EMP> <EMPNO>412</EMPNO> <EMPNAME>Jackson</EMPNAME> <SALARY>40000</SALARY> </EMP> </EMPLOYEES>
FROM emp_tab e
UPDATE profile t SET value(t) = updateXML(value(t),'/UCLEADS/ScholarProfile/Major/text()','CS') WHERE existsNode(value(t), '/UCLEADS/ScholarProfile[Major="Computer Science"]') = 1; isFragment() returns (1) if the XMLType contains XML document fragment. getClobVal() converts the XMLType document into CLOB object. getRootElement() get the root element of the XML document. getNameSpace() get the namespace of the root element of the XML document.
azharpro@gmail.com