Oracle PL/SQL Tutorial/XML/xdburitype

Материал из SQL эксперт
Перейти к: навигация, поиск

Get xdburitype

SQL> select xdburitype("/xmldata/Products.xml") from dual;

XDBURITYPE("/XMLDATA/PRODUCTS.XML")(URL, SPARE)
------------------------------------------------------
XDBURITYPE("/xmldata/Products.xml", NULL)
1 row selected.
SQL>


Use xdbURIType

SQL> create table myTable(
  2     id number(9),
  3     myValue xmltype
  4  );
Table created.
SQL> begin
  2    dbms_xmlschema.registerSchema ("http://d.ru/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.ru/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.