Saturday, November 7, 2009

CRITICAL SKILL 8.4 Store XML in Oracle XML DB


Team Fly 


Page 283




3. When can the xmlattributes() function be called?



4. What corresponding SQL clause must accompany an xmlagg() function?



CRITICAL SKILL 8.4
Store XML in Oracle XML DB



Databases are relational and XML is hierarchical, so prior to the introduction of Oracle XML DB there had been no simple, elegant way to integrate the two. Traditionally, developers have had two choices: either use a parser to deconstruct the document data into relational data and store it as such in the database, or store the entire document as a text file, preserving its text-based structure. Oracle XML DB starts it all off by first solving the problem of representing an XML document in its native format—the XMLType.



The Native XMLType



The XMLType was created to be able to preserve the XML paradigm while getting the benefits of relational performance and scalability. It is a native server data type that allows the database to understand that a column or table contains XML—in the same way that the DATE data type allows the database to understand that a column contains a date. The twist is that the XMLType also provides methods that allow common operations such as schema validation and XSL transformations to be performed on XML content.



The XMLType data type can be used just like any other data type, such as when creating a column in a relational table, when declaring PL/SQL variables, and when defining and calling PL/SQL procedures and functions. Since XMLType is an object type, it is also possible to create a table of XMLType. The following listing shows how to create a simple table with an XMLType column:




SQL> create table purchase_order
2 (
3 po_no number(9),
4 po_file xmltype
5 )









Progress Check Answers


1. The hierarchical data structure is a data structure that has several levels arranged in a tree-like structure.


2. xmlelement() is used to define all elements with the XML type. All XML types start with a root element.


3. The xmlattributes() function can only be called within an xmlelement() function call. The xmlattributes() function builds attributes for an element.


4. xmlagg() must be accompanied by a group by clause.




Team Fly 

No comments:

Post a Comment