title: xml in oracle encounter single-row subquery returns more than one row
body: <p>here is my code for creating tables and inserting xml columns. </p>
  
  <p>--drop schema</p>
  
  <pre><code>BEGIN
  DBMS_XMLSCHEMA.DELETESCHEMA(
     'http://xmlns.oracle.com/xdb/schemas/HZHE18/handBook',
     dbms_xmlschema.DELETE_CASCADE_FORCE);
  END;
  </code></pre>
  
  <p>--register binary schema</p>
  
  <pre><code>BEGIN
  DBMS_XMLSCHEMA.REGISTERSCHEMA(SCHEMAURL =&gt; 'handBook',
  schemadoc =&gt; '&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt;
  
  &lt;xs:annotation&gt;
      &lt;xs:documentation&gt; Author: Andy(Haichuan) Zheng Schema for Web Handbook data
      &lt;/xs:documentation&gt;
  &lt;/xs:annotation&gt;
  
  &lt;xs:simpleType name="code-style"&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:pattern value="[A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9]"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="level-style"&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="Undergraduate"/&gt;
          &lt;xs:enumeration value="Postgraduate"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="email-style"&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:pattern value="[^@]+@[^\.]+\..+"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="point_lvl_type"&gt;
      &lt;xs:restriction base="xs:positiveInteger"&gt;
          &lt;xs:enumeration value="3"/&gt;
          &lt;xs:enumeration value="6"/&gt;
          &lt;xs:enumeration value="12"/&gt;
          &lt;xs:enumeration value="24"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="offered_type"&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="First semester"/&gt;
          &lt;xs:enumeration value="Second semester"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="mode_type"&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="Day"/&gt;
          &lt;xs:enumeration value="Evening"/&gt;
          &lt;xs:enumeration value="Off-campus"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="campus_type"&gt;
      &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="Caulfield"/&gt;
          &lt;xs:enumeration value="Gippsland"/&gt;
          &lt;xs:enumeration value="Sunway"/&gt;
          &lt;xs:enumeration value="Clayton"/&gt;
          &lt;xs:enumeration value="South Africa"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:element name="handbook"&gt;
      &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element ref="page_info" minOccurs="1" maxOccurs="unbounded"/&gt;
              &lt;xs:element ref="unit" minOccurs="1" maxOccurs="unbounded"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;xs:element name="page_info"&gt;
      &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="sub_date" type="xs:date"/&gt;
          &lt;/xs:sequence&gt;
          &lt;xs:attribute name="author" type="xs:string"/&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;xs:element name="unit"&gt;
      &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="u_name" type="xs:string"/&gt;
              &lt;xs:element name="level" type="level-style"/&gt;
              &lt;xs:element ref="chief_examiner"/&gt;
              &lt;xs:element name="point_lvl" type="point_lvl_type"/&gt;
              &lt;xs:element name="prerequisites" type="code-style" maxOccurs="unbounded"
                  minOccurs="0"/&gt;
              &lt;xs:element name="prohibitions" type="code-style" maxOccurs="unbounded"
                  minOccurs="0"/&gt;
              &lt;xs:element ref="availability"/&gt;
              &lt;xs:element name="synopsis" type="xs:string"/&gt;
              &lt;xs:element name="assessment" type="xs:string"/&gt;
              &lt;xs:element name="contact_hours" type="xs:string"/&gt;
          &lt;/xs:sequence&gt;
          &lt;xs:attribute name="code" type="code-style"/&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;xs:element name="chief_examiner"&gt;
      &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="name" type="xs:string"/&gt;
              &lt;xs:element name="email" type="email-style"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;xs:element name="availability"&gt;
      &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="offered" type="offered_type" maxOccurs="unbounded"/&gt;
              &lt;xs:element name="mode" type="mode_type" maxOccurs="unbounded"/&gt;
              &lt;xs:element name="campus" type="campus_type" maxOccurs="unbounded"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;/xs:schema&gt;',
  LOCAL =&gt; TRUE,
  GENTYPES =&gt; FALSE,
  GENTABLES =&gt; FALSE,
  FORCE =&gt; FALSE,
  options =&gt; DBMS_XMLSCHEMA.REGISTER_BINARYXML);
  end;
  </code></pre>
  
  <p>--drops and clean recycle bin</p>
  
  <pre><code>drop table units_handbook purge;
  
  PURGE RECYCLEBIN;
  </code></pre>
  
  <p>--create tables
       CREATE TABLE units_handbook (
      unit_code varchar2(7) PRIMARY KEY,
      XML_detail XMLTYPE NOT NULL)
      XMLTYPE COLUMN XML_detail STORE AS BINARY XML
      XMLSCHEMA
      "<a href="http://xmlns.oracle.com/xdb/schemas/HZHE18/handBook" rel="nofollow">http://xmlns.oracle.com/xdb/schemas/HZHE18/handBook</a>"
      ELEMENT "handbook";</p>
  
  <p>-- populate tables</p>
  
  <pre><code>insert into units_handbook values('FIT2077', 
  '&lt;handbook&gt;
      &lt;page_info author = "Haichuan Zheng"&gt;
          &lt;sub_date&gt;2013-05-28&lt;/sub_date&gt;
      &lt;/page_info&gt;
      &lt;unit code="FIT2077"&gt;
          &lt;u_name&gt;Advanced Data Management&lt;/u_name&gt;
          &lt;level&gt;Undergraduate&lt;/level&gt;
          &lt;chief_examiner&gt;
               &lt;name&gt;Mr Lindsay Smith&lt;/name&gt;
               &lt;email&gt;Lindsay.Smith@monash.edu&lt;/email&gt;
          &lt;/chief_examiner&gt;
          &lt;point_lvl&gt;6&lt;/point_lvl&gt;
          &lt;prerequisites&gt;FIT1004&lt;/prerequisites&gt;
         &lt;prerequisites&gt;CSE2132&lt;/prerequisites&gt;
      &lt;prohibitions&gt;CSE3000&lt;/prohibitions&gt;
          &lt;prohibitions&gt;FIT3118&lt;/prohibitions&gt;
      &lt;prohibitions&gt;FIT4038&lt;/prohibitions&gt;
      &lt;availability&gt;
          &lt;offered&gt;First semester&lt;/offered&gt;
          &lt;mode&gt;Day&lt;/mode&gt;
          &lt;campus&gt;Caulfield&lt;/campus&gt;
      &lt;/availability&gt;
      &lt;synopsis&gt;&lt;![CDATA[This unit extends the study from FIT1004 Data management. 
          FIT2077 will introduce more advanced concepts in the areas of database design, SQL, 
          query optimisation and the handling of unstructured data (XML) both externally
          and within a database. The issue of "Big Data" and the role played by BI technologies 
          and data warehouses will be explored.]]&gt;&lt;/synopsis&gt;
      &lt;assessment&gt;Examination (3 hours): 60%; In-semester assessment: 40%&lt;/assessment&gt;
      &lt;contact_hours&gt;2 hrs lectures/wk, 2 hrs laboratories/wk&lt;/contact_hours&gt;
  &lt;/unit&gt;
  &lt;/handbook&gt;');
  
  insert into units_handbook values('FIT4038', 
  '&lt;handbook&gt;
  &lt;page_info author = "Haichuan Zheng"&gt;
      &lt;sub_date&gt;2013-05-28&lt;/sub_date&gt;
  &lt;/page_info&gt;
  &lt;unit code="FIT4038"&gt;
      &lt;u_name&gt;Database management and implementation&lt;/u_name&gt;
      &lt;level&gt;Postgraduate&lt;/level&gt;
      &lt;chief_examiner&gt;
          &lt;name&gt;Associate Professor David Taniar&lt;/name&gt;
          &lt;email&gt;David.Taniar@monash.edu&lt;/email&gt;
      &lt;/chief_examiner&gt;
      &lt;point_lvl&gt;6&lt;/point_lvl&gt;
      &lt;prerequisites&gt;FIT9019&lt;/prerequisites&gt;
      &lt;prerequisites&gt;FIT9003&lt;/prerequisites&gt;
      &lt;prohibitions&gt;FIT3118&lt;/prohibitions&gt;
      &lt;prohibitions&gt;CSE3000&lt;/prohibitions&gt;
      &lt;availability&gt;
          &lt;offered&gt;First semester&lt;/offered&gt;
          &lt;mode&gt;Day&lt;/mode&gt;
          &lt;campus&gt;Caulfield&lt;/campus&gt;
      &lt;/availability&gt;
      &lt;synopsis&gt;&lt;![CDATA[This unit looks at the design and implementation issues of 
          database management systems. Advanced database design using the object-relational approach 
          and multi-dimensional database design are explored. Record, file 
          and index structures are dealt with at the basic level. 
          Higher level details of consistency, atomicity and durability are
          introduced along with modern trends in databases.]]&gt;&lt;/synopsis&gt;
      &lt;assessment&gt;Examination (3 hours): 60%; In-semester assessment: 40%&lt;/assessment&gt;
      &lt;contact_hours&gt;2 hrs lectures/wk, 2 hrs laboratories/wk&lt;/contact_hours&gt;
  &lt;/unit&gt;
  &lt;/handbook&gt;');
  </code></pre>
  
  <p>my question is when i want to retrieve all u_name within xml format i get this error saying ORA-01427: single-row subquery returns more than one row</p>
  
  <p>here is my code </p>
  
  <pre><code>  select xmlelement("unit",xmlelement("u_name",
    (
     SELECT
        EXTRACTVALUE(u.XML_detail, '/handbook/unit/u_name')
      FROM
         units_handbook u
   )
    ) )
    from units_handbook;
  </code></pre>