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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:27:07+00:00 2026-06-11T01:27:07+00:00

Let us say I have two table types (tables of object types) that I

  • 0

Let us say I have two table types (tables of object types) that I want to compare for equality…

The object types have multiple fields, say, an integer, varchar2, and date.

I have seen examples where people use MULTISET EXCEPT in order to effectively do a MINUS on two tables of INTEGER.

But this does not work with two tables of complex object types.

Also I have seen mentioned the use of MAP MEMBER FUNCTION in order to make complex collections work when using the SET operator, but no mention of MULTISET functionality.

The current way I am comparing for equality is to take table type 1 (TT1) and table type 2 (TT2) and say they are equal if TT1 MINUS TT2 = 0 AND TT2 MINUS TT1 = 0. But here I am just selecting the PK from both tables for the MINUS, I would also like to be able to compare more than one field.

I am hoping MULTISET is faster?

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-06-11T01:27:08+00:00Added an answer on June 11, 2026 at 1:27 am

    Yes, you can use a MAP MEMBER FUNCTION to support comparing nested tables of types.

    --#1: Create object
    create or replace type type1 is object
    (
        a integer,
        b varchar2(100),
        c date,
        map member function compare return raw
    );
    /
    
    --#2: Create map function for comparisons.
    --Returns the concatenated RAW of all attributes.
    --Note that this will consider NULLs to be equal!
    create or replace type body type1 as
        map member function compare return raw is
        begin
            return
                utl_raw.cast_to_raw(to_char(a))||
                utl_raw.cast_to_raw(b)||
                utl_raw.cast_to_raw(to_char(c, 'DD-MON-YYYY HH24:MI:SS'));
    
        end;
    end;
    /
    
    --#3: Create nested table of the types
    create or replace type type1_nt is table of type1;
    /
    
    --#4: Compare.
    --You could use MULTISET, but it's easier to use regular operators like "<>" "and =".
    declare
        tt1 type1_nt := type1_nt(type1(0, 'A', date '2000-01-01'),
                                 type1(0, 'A', date '2000-01-01'));
        tt2 type1_nt := type1_nt(type1(0, 'B', date '2000-01-01'),
                                 type1(0, 'B', date '2000-01-01'));
        tt3 type1_nt := type1_nt(type1(0, 'B', date '2000-01-01'),
                                 type1(0, 'B', date '2000-01-01'));
    begin
        if tt1 <> tt2 and tt2 = tt3 then
            dbms_output.put_line('Pass');
        else
            dbms_output.put_line('Fail');
        end if;
    end;
    /
    

    I don’t know if this would be faster than manually comparing each attribute. But I would guess the difference won’t be significant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with similar columns - let's say table A with column
Let's say I have two tables that look like this: TH TH TH TH
Let's say we have two tables: 'Car' and 'Part', with a joining table in
Let's say I have two tables: Table A ProdID | PartNumber | Data... 1
Let's say I have two tables: TABLE A MessageID | Message 1 | Hello
I have two tables that I want to join into one table and use
Let's say I have two tables. A students table and an observations table. If
Let's say have have two tables, A and B. A contains fields: id, a1,
Let's say i have two tables in db: Car and Part. Car owns arbitrialy
Let's say I have two tables, users and notes. Let's say the schemas look

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.