title: Oracle PL/SQL function to iterate through multiple rows
body: <p>A sample record in my xmltype is,</p>
  
  <p><code>1 , XMLTYPE('&lt;books&gt;  &lt;book minprice = "10" maxprice="25"&gt; .. &lt;/book&gt; &lt;book minprice = "15" maxprice="20"&gt; &lt;/books&gt;');</code></p>
  
  <p>Following is my pl/sql function to find the max and min price in the whole plsql , which is incomplete.</p>
  
  <pre><code>create or replace 
  FUNCTION DiffMaxMinPrice
   return double precision
  is 
   diffprice double precision := 0;
   minprice long; 
   maxprice long;
   value long;
  begin
   SELECT  x.* into minprice , maxprice 
         FROM sampletable ,
              XMLTABLE ('//book'
                        PASSING sampletable.xmlcol
                        COLUMNS maxprice VARCHAR2(30) PATH '@maxprice',
                                minprice VARCHAR2(30) PATH '@minprice') x 
                                where sampletable.indexid = 2;
  
  
  
   return 1;
  end;
  </code></pre>
  
  <p>The select query returns multiple values, how to iterate through all those values.</p>
  
  <p>I am using Oracle 11gr2.</p>