Loading XML into Relational Tables

Loading XML data into relational tables is needed when we receive XML data from other applications. The available approaches include using the XMLTable() function, creating SQL/XML or XQuery views instead of triggers, using DBMS_XMLSTORE, and using the Oracle XDK Java XSU oracle.xml.sql.dml.OracleXMLSave package. Among these approaches, using XMLTable() is the easiest approach and thus is the method we will discuss now.

To load XML data into relational tables with XMLTable(), you need to insert XML from the relational view created by XMLTable(). For example, the following table stores email templates (loading_xml.sql):

Listing 9-9 Inserting Data to Relational Table Using XMLTable() View

CREATE TABLE email_template_tbl ...

Get Oracle Database 11g Building Oracle XML DB Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.