Use sys.xmltype.createxml to add XML data to table : XMLTYPE « XML « Oracle PL/SQL Tutorial






SQL> CREATE TABLE testxml (id NUMBER(3), dt SYS.XMLTYPE);

Table created.

SQL>
SQL>
SQL> INSERT INTO testxml VALUES(111,
  2  sys.xmltype.createxml(
  3  '<?xml version="1.0"?>
  4  <customer>
  5  <name>Joe Smith</name>
  6  <title>Mathematician</title>
  7  </customer>'))
  8  /

1 row created.

SQL>
SQL> SET LONG 2000
SQL>
SQL> SELECT *
  2  FROM testxml
  3  /

ID     DT
----------------------------------------------------------------------------------------
111    <?xml version="1.0"?><customer><name>Joe Smith</name><title>Mathematician</title></customer>


SQL>
SQL> SELECT t.dt.getclobval()
  2  FROM testxml t
  3  WHERE ROWNUM < 2
  4  /

T.DT.GETCLOBVAL()
--------------------------------------------------------------------------------
<?xml version="1.0"?>
<customer>
<name>Joe Smith</name>
<title>Mathematician</title>
</customer>


SQL>
SQL> drop table testxml;

Table dropped.

SQL>
SQL>








33.4.XMLTYPE
33.4.1.XMLTYPE column
33.4.2.Use sys.xmltype.createxml to add XML data to table
33.4.3.Retrieve value from SYS.XMLTYPE column
33.4.4.Individual fields from the XMLTYPE'd column may be found using the EXTRACTVALUE function like this:
33.4.5.Creation of tables using XMLType data type and set the xml schema
33.4.6.Insert xml document to a XMLType column with xmltype function
33.4.7.PL/SQL ability to access text within an XML document in the database
33.4.8.Query xmltype column
33.4.9.Store an XMLType type data in clob
33.4.10.Use value function with single xmltype table
33.4.11.Use xmltype to convert xml string to xmltype data