Du behöver ett funktionsbaserat unikt index :
create table tt (
DealID number(10) primary key,
LegID number(10),
OrigID number(10),
Description varchar2(200 char)
);
create unique index tt_leg_orig_dscr_uk on tt (
case when description = 'A' then description end,
case when description = 'A' then legid end,
case when description = 'A' then origid end
);
insert into tt values (1, 1, 1, 'A');
1 row(s) inserted.
insert into tt values (2, 1, 1, 'A');
ORA-00001: unique constraint (XXXXX.TT_LEG_ORIG_DSCR_UK) violated
insert into tt values (2, 1, 2, 'A');
1 row(s) inserted.
select * from tt;
DEALID LEGID ORIGID DESCRIPTION
-----------------------------------
1 1 1 A
2 1 2 A
2 rows returned in 0.01 seconds
insert into tt values (3, 1, 1, 'B');
1 row(s) inserted.
insert into tt values (4, 1, 1, 'B');
1 row(s) inserted.
select * from tt order by 1;
DEALID LEGID ORIGID DESCRIPTION
-----------------------------------
1 1 1 A
2 1 2 A
3 1 1 B
4 1 1 B
4 rows returned in 0.01 seconds
Som du kan se fungerar det unika indexet endast med poster med beskrivning ='A', det tillåter att ha icke-unika poster för olika beskrivningar.