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 8471671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:51:34+00:00 2026-06-10T16:51:34+00:00

I have two user defined collection types. The first type has the columns: CREATE

  • 0

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?

  • 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-10T16:51:35+00:00Added an answer on June 10, 2026 at 4:51 pm

    May be something like this.

    declare
        TYPE t_coll_1 is TABLE OF collection_1;
        v_coll_1    t_coll_1;
    
        TYPE t_coll_2 is TABLE OF collection_2;
        v_coll_2          t_coll_2;
    
    begin
        /* populate v_coll_1 */
        /* populate v_coll_2 */
    
        for i in v_coll_2.first.. v_coll_2.last
        loop
           for j in v_coll_1.first.. v_coll_1.last
           loop
              if v_coll_2(i).currency_code = v_coll_1(j).currency_code
              then
                  v_coll_2(i).total_amount := v_coll_2(i).total_amount + v_coll_1(j).total_amount;
              end if;
           end loop;
        end loop;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes, user and role, defined as: public class User : Entity
I have two user types in my application: Investors and Advisors , they both
I have two colors in my .NET application that are user defined. I'd like
I have two models: User (pre-defined by Django) and UserProfile that are connected through
I have two models in Django: User (pre-defined by Django) and UserProfile. The two
I have defined a many-to-many relationship between my two entity classes User and Permission.
I have some logic, which defines and uses some user-defined types, like these: class
I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1)
I have two User Controls already created now I want to use one as
I have two user controls, in one of them I have a textbox, i

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.