Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

extractvalue, extract, xmlsequence

User_5OAFPMar 18 2013 — edited Mar 19 2013
Could someone explain what extractvalue, xmlsequence and extract is doing in the following query:
select
   extractvalue(value(a),'Notebook/@Brand') As Brand
  ,extractvalue(value(a),'Notebook/@Model') As Model
from prod_xml_tab b,
table( xmlsequence( extract( demo_field,'Product/Notebook' ) ) ) a
where demo_field is not null;
I went through documentation and still don't get it, and need some basic explanation step by step. for example, what is actually EXTRACT returning for first and second row?
the code for table and data is as follows:
create table prod_xml_tab (demo_field xmltype);

insert into prod_xml_tab values('
  <Product type="Laptop">
              <Notebook Brand="HP" Model="Pavilion dv6-3132TX Notebook">
                          <Harddisk>640 GB</Harddisk>
                          <Processor>Intel Core i7</Processor>
                          <RAM>4 GB</RAM>
                          <Price>1189</Price>
                          <Display Type="LED" MonitorSize="15.6"/>
                          <Weight>4.14</Weight>
              </Notebook>
              <Notebook Brand="HP" Model="HP Pavilion dv6-3032TX Notebook">
                          <Harddisk>640 GB</Harddisk>
                          <Processor>Intel Core i7</Processor>
                          <RAM>6 GB</RAM>
                          <Price>1104</Price>
                          <Display Type="LED" MonitorSize="15.6"/>
                          <Weight>4.1</Weight>
              </Notebook>
              <Notebook Brand="HP" Model="Pavilion dv6-3079TX Notebook">
                          <Harddisk>500 GB</Harddisk>
                          <Processor>Intel Core i7</Processor>
                          <RAM>4 GB</RAM>
                          <Price>1099</Price>
                          <Display Type="LED" MonitorSize="15.6"/>
                          <Weight>4.14</Weight>
              </Notebook>
</Product>');

insert into prod_xml_tab values('
<Product>
              <Notebook Brand="Toshiba" Model="Satellite A660/07R 3D Notebook">
                          <Harddisk>640 GB</Harddisk>
                          <Processor>Intel Core i7</Processor>
                          <RAM>4 GB</RAM>
                          <Price>1444</Price>
                          <Display Type="LED" MonitorSize="15.6"/>
                          <Weight>4.88</Weight>
              </Notebook>
</Product>');
This post has been answered by BluShadow on Mar 18 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2013
Added on Mar 18 2013
12 comments
1,908 views