Oracle PL/SQL/System Packages/dbms xmlschema
Версия от 13:45, 26 мая 2010; (обсуждение)
dbms_xmlschema.registerSchema
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.
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.