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

  • Home
  • SEARCH
  • 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 7519261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:52:24+00:00 2026-05-30T01:52:24+00:00

I just implemented the ODCIAggregate Interface to create a custom aggregation function. It works

  • 0

I just implemented the ODCIAggregate Interface to create a custom aggregation function. It works quite well and fast, but I would like it to do a little something more. I have a statement going like this:

SELECT SomeId, myAggregationFunction(Item) FROM
(
  SELECT 
    Foo.SomeId, 
    SomeType(Foo.SomeValue, Foo.SomeOtherValue) AS Item
  FROM
    Foo
  ORDER BY Foo.SomeOrderingValue
)
GROUP BY SomeId;

My problem is that items aren’t passed to the ODCIAggregateIterate function of my implementation in the same order that my inner (ordered) SELECT returns them.

I’ve Googled around and didn’t find any Oracle-provided way to do so. Has any of you experimented a similar problem based on that requirement?

Thanks!

  • 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-05-30T01:52:26+00:00Added an answer on May 30, 2026 at 1:52 am

    Have you considered using COLLECT instead of data cartridge?

    At least for string aggregation, the COLLECT method is simpler and much faster. It does make your SQL a little weirder though.

    Below is an example using just simple string concatenation.

    --Create a type
    create or replace type sometype as object
    (
        someValue varchar2(100),
        someOtherValue varchar2(100)
    );
    
    --Create a nested table of the type.
    --This is where the performance improvement comes from - Oracle can aggregate
    --the types in SQL using COLLECT, and then can process all the values at once.
    --This significantly reduces the context switches between SQL and PL/SQL, which
    --are usually more expensive than the actual work.
    create or replace type sometypes as table of sometype;
    
    --Process all the data (it's already been sorted before it gets here)
    create or replace function myAggregationFunction(p_sometypes in sometypes)
    return varchar2 is
        v_result varchar2(4000);
    begin
        --Loop through the nested table, just concatenate everything for testing.
        --Assumes a dense nested table
        for i in 1 .. p_sometypes.count loop
            v_result := v_result || ',' ||
                p_sometypes(i).someValue || '+' || p_sometypes(i).someOtherValue;
        end loop;
    
        --Remove the first delimeter, return value
        return substr(v_result, 2);
    end;
    /
    
    --SQL
    select someId
        ,myAggregationFunction
        (
            cast
            (
                --Here's where the aggregation and ordering happen
                collect(sometype(SomeValue, SomeOtherValue)
                    order by SomeOrderingValue)
                as someTypes
            )
        ) result
    from
    (
        --Test data: note the unordered SoemOrderingValue.
        select 1 someId, 3 SomeOrderingValue, '3' SomeValue, '3' SomeOtherValue
        from dual union all
        select 1 someId, 1 SomeOrderingValue, '1' SomeValue, '1' SomeOtherValue
        from dual union all
        select 1 someId, 2 SomeOrderingValue, '2' SomeValue, '2' SomeOtherValue
        from dual
    ) foo
    group by someId;
    
    --Here are the results, aggregated and ordered.
    SOMEID  RESULT
    ------  ------
    1       1+1,2+2,3+3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just implemented a number of custom counter_cache s using code like this: def
I just implemented uploadify in my project, and I noticed what seems like an
Is there a way just like multidatatrigger behavior of WPF also implemented in Silverlight
I just implemented a star rating system on my site, but I'm having a
I have just implemented a RequiredFieldValidatior with ValidationSummary by setting a ValidationGroup. It works
I just implemented a ListView inside a LinearLayout, but I need to define the
I've just implemented an interface with a third party payment service, for subscriptions to
I've just implemented Paypal's express checkout API to one of our websites, which works
I've just implemented MobFox but for the last 4 days my only response back
I just implemented a remember me feature for a user login on a website.

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.