Tom -
Gotcha. After thinking about this a while and reading a
very, very applicable past thread of yours (</code>
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:42304816945767 <code>,
this is real easy, as shown below by my new test case
that uses a base table with a primary key:
drop materialized view v1;
-- Recreate my table, being sure to add a column such
-- that a primary key can be defined. The "name" column
-- is not a suitable PK by itself because a single person
-- can have more than one sales commission.
drop table t1;
create table t1
(name varchar2(10),
sales_commission_seq number,
sales_commission number);
alter table t1 add primary key (name, sales_commission_seq);
create sequence my_seq;
insert into t1 values ('Tom',my_seq.nextval,40);
insert into t1 values ('Steve',my_seq.nextval,40);
insert into t1 values ('Tom',my_seq.nextval,40);
insert into t1 values ('Steve',my_seq.nextval,20);
create materialized view log on t1
with primary key including new values;
create materialized view v1
refresh complete on commit as
select name, sum(sales_commission) ssc
from t1
group by name;
alter table v1 add constraint sales_commission_chk
check (ssc <= 100);
-- Now, add a couple of rows, committing each time.
-- The first one will
-- succeed, but the second one should cause the
-- ORA-12008 error.
insert into t1 values ('Tom',my_seq.nextval,10);
commit;
insert into t1 values ('Steve',my_seq.nextval,50);
commit;
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This is all fine and dandy, but is there an easy way to detect
"limit-breaking" inserts into my main table without
having to commit the changes first? I'd love for this
to operate similarly to the way a regular check constraint
on a regular table works.
Thanks so much for your fine work!
Tom