I have two user defined collection types. The first type has the columns:
CREATE OR REPLACE
TYPE collection_1 as OBJECT
(
currency_code varchar2(30),
amount number
)
I have populated this collection inside a stored procedure using oracle bulk collect.So now let us say, the collection has values like this:
currency_code amount
CAD 100
USD 50
CAD 120
USD 30
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:
CREATE OR REPLACE
TYPE collection_2 as OBJECT
(
currency_code varchar2(30),
total_amount number
)
And initialized it like this:
currency_code total_amount
CAD 0
USD 0
GBP 0
Now I want to iterate over the collection_1 and populate collection_2 so that collection_2 reads like this:
currency_code total_amount
CAD 220 --i.e.100+120
USD 80
GBP 0
How can I do it?
May be something like this.