はい、を使用しMAP MEMBER FUNCTION
て、型のネストされたテーブルの比較をサポートできます。
--#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;
/
これが各属性を手動で比較するよりも速いかどうかはわかりません。しかし、違いは重要ではないと思います。