I am trying to get the data from a Oracle View created on XML Type column.
e.g: Following is the XSD:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:element name="MsrFact" type="MsrNode"/><xsd:complexType name="MsrNode"><xsd:sequence><xsd:element name="shipTo" type="MsrValue"/><xsd:element name="billTo" type="MsrValue"/><xsd:element name="FormulaeItem" type="MsrValue" maxOccurs="10"/></xsd:sequence></xsd:complexType><xsd:complexType name="MsrValue"><xsd:sequence><xsd:element name="name" type="xsd:string"/><xsd:element name="street" type="xsd:integer"/></xsd:sequence></xsd:complexType></xsd:schema>
Inserted xml is:
<MsrFact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><MsrNode><shipTo><name>shipTo</name></shipTo><billTo><name>billTo</name></billTo><FormulaeItem><name>FormulaeItem1</name></FormulaeItem><FormulaeItem><name>FormulaeItem2</name><street>100</street></FormulaeItem><FormulaeItem><name>FormulaeItem3</name></FormulaeItem></MsrNode></MsrFact>
Table:
temptab(
ogrid number(10),
xdata xmltype);
VIEW:
CREATE OR REPLACE VIEWMsrFactView(orgid,shipTo,shipToR, billTo,billToR, FormulaeItem,FormulaeItemR)AS SELECT ogrid,extractValue(xdata, '/MsrFact/shipTo/name'),extractValue(xdata, '/MsrFact/shipTo/street'),extractValue(xdata, '/MsrFact/billTo/name'),extractValue(xdata, '/MsrFact/billTo/street'),extractValue(xdata, '/MsrFact/FormulaeItem/name'),extractValue(xdata, '/MsrFact/FormulaeItem/street')FROM temptab;
I cannot write a direct select query on this view as it gives the error
SQL Error: ORA-01427: single-row subquery returns more than one row
01427. 00000 - "single-row subquery returns more than one row"
Is there any way to get the data from this view? Thanks !