title: oracle update collection
body: <p>I have two user defined collection types. The first type has the columns:</p>
  
  <pre><code>CREATE OR REPLACE
  TYPE collection_1 as OBJECT
  (
  currency_code   varchar2(30),
  amount   number
  )
  </code></pre>
  
  <p>I have populated this collection inside a stored procedure using oracle bulk collect.So now let us say, the collection has values like this:</p>
  
  <pre><code>currency_code     amount
  CAD               100
  USD               50
  CAD                120
  USD               30
  </code></pre>
  
  <p>Now I want perform some aggregate functions on this collection and populate another collection that will store the total amount per currency. So I defined another collection like this:</p>
  
  <pre><code>CREATE OR REPLACE
  TYPE collection_2 as OBJECT
  (
  currency_code   varchar2(30),
  total_amount   number
  )
  </code></pre>
  
  <p>And initialized it like this:</p>
  
  <pre><code>currency_code    total_amount
  CAD               0
  USD               0
  GBP               0
  </code></pre>
  
  <p>Now I want to iterate over the collection_1 and populate collection_2 so that collection_2 reads like this:</p>
  
  <pre><code>currency_code    total_amount
  CAD               220              --i.e.100+120
  USD               80
  GBP               0
  </code></pre>
  
  <p>How can I do it?</p>