Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:07:20+00:00 2026-06-01T17:07:20+00:00

I am trying to get the data from a Oracle View created on XML

  • 0

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 VIEW

MsrFactView(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 !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:07:21+00:00Added an answer on June 1, 2026 at 5:07 pm

    extractValue only extracts a single value from the give path, but as the FormulaeItem can be many, you can’t use extractValue here.
    Besides, using extractValue is a old and not recommended way for querying XML. You should use the new XMLTable approach.

    create or replace view MsrFactView as
    select tt.ogrid,
    st.name shiptoName, st.street shiptoStreeet,
    bt.name billtoName ,bt.street billtoStreet,
    fi.name formulaeitemname ,fi.street formulaeitemstreet
    FROM
    temptab tt,
    XMLTABLE(
        '/MsrFact/MsrNode'
        passing tt.xdata
        columns
            shipto  XMLTYPE path '/MsrNode/shipTo'
            billto  XMLTYPE path '/MsrNode/billTo'
            formulaeitem XMLTYPE path '/MsrNode/FormulaeItem'
    ) nd,
    XMLTable (
        '/shipTo'
        passing nd.shipto
        columns
        name varchar2(4000) path '/shipTo/name'
        street number path '/shipTo/street'
    ) st,
    XMLTABLE (
        '/billTo'
        passing nd.billto
        columns
        name varchar2(4000) path '/billTo/name'
        street number path '/billTo/street'
    ) bt,
    XMLTable (
        '/FormulaeItem'
        passing nd.formulaeitem
        columns
        name varchar2(4000) path '/FormulaeItem/name'
        street number path '/FormulaeItem/street'
    ) fi
    /
    

    One thing to remember though is that you won’t get one row per one ‘MsrNode’, as you have 1-n FormulaeItem per MsrNode. Think of it as a SQL query joining 2 tables having a 1-n relationship. Just like in that case, you will get ‘n’ rows per every 1 row of the parent table.

    So in your case, per every MsrNode, you will get as many rows in your view, as the count of FormulaeItems in that node.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I' trying to get some data from Oracle via ODBC to mySQL database. And
I created SSIS will do task like get data from oracle to sql server.i
I am trying to get data from my interface, written in c, to another
What is the best way of handling trying to get data from a DataReader
I'm trying to get character data from www.wowarmory.com using PHP and cURL. The code
I am trying to get data back from a PHP file assigned with GET
I'm trying to get some data from a table, where the tag has no
for example I'm trying to get the data from database like: using (ExplorerDataContext context
I have sugar crm instance and i was trying to get some data from
I'm trying to get the video data from this youtube playlist feed and add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.