XMLTYPE with xml schema : Insert « XML « Oracle PL/SQL Tutorial






SQL> create table myTable(
  2     id number(9),
  3     myValue xmltype
  4  );

Table created.

SQL> begin
  2    dbms_xmlschema.registerSchema ('http://d.com/myType.xsd',xdbURIType('/xsd/myType.xsd').getClob(),True,True,False,True);
  3  end;
  4  /


SQL>
SQL> insert into myTable values (67, XMLTYPE('<myType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://d.com/myType.xsd">
  2       <value1>1</value1>
  3       <value2>2</value2>
  4   </myType>'))
  5  /

1 row created.

SQL>
SQL> select * from myTable;



   emp
Number
------
MYVALUE
------------------------------------------------------
    67
<myType xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:noNamespaceSch

1 row selected.

SQL>
SQL> drop table myTable;

Table dropped.








33.2.Insert
33.2.1.Insert XML document to database
33.2.2.XMLTYPE with xml schema
33.2.3.Reference one element