I have created two identical tables which list all the exceptions with regards to certain rules of products in the data base. table one is for week 1 table two is for week two the exception are just view on a weekly basis and no correction is made in the data base. week twos data includes the exceptions in week one i want to exclude week ones exceptions from week twos. only to view the new exceptions
I suggest you add a timestamp to the tables and select/filter on this timestamp.
This way you also can put all exceptions into one table and just define two views.
I'm no good with PL/SQL, but maybe you can adapt my MySQL-sample:
CREATE DATABASE timetest;
CONNECT timetest;
CREATE TABLE errorlog (
stamp TIMESTAMP NOT NULL ,
error VARCHAR(255) NOT NULL
);
INSERT into errorlog (`stamp`, `error`)
VALUES (DATE_SUB(CURDATE(),INTERVAL 8 DAY), 'old');
INSERT into errorlog (`stamp`, `error`)
VALUES (NOW(), 'new');
SELECT * FROM errorlog WHERE stamp>DATE_SUB(CURDATE(),INTERVAL 7 DAY);
SELECT * FROM errorlog WHERE stamp<DATE_SUB(CURDATE(),INTERVAL 7 DAY);
DROP DATABASE timetest;
Gives me:
mysql> SELECT * FROM errorlog WHERE stamp>DATE_SUB(CURDATE(),INTERVAL 7 DAY);
+---------------------+-------+
| stamp | error |
+---------------------+-------+
| 2009-01-29 01:44:38 | new |
+---------------------+-------+
mysql> SELECT * FROM errorlog WHERE stamp<DATE_SUB(CURDATE(),INTERVAL 7 DAY);
+---------------------+-------+
| stamp | error |
+---------------------+-------+
| 2009-01-21 00:00:00 | old |
+---------------------+-------+
Oracle has a MINUS operator so you can do
SELECT col_a, col_b... FROM table_new
MINUS
SELECT col_a, col_b... from table_old
That works as long as the columns have corresponding datatypes (so will work with SELECT * if the tables have identical structures).
There also may be some advantage to breaking the table into partitions by year/week number.
To really help you we need more information. Are you talking about tables or views ("... the exception are just view on a weekly basis.. " part confused me)?
If you could provide a short complete example (yes - stolen from Tom Kyte) we could provide a complete answer. That is if the above have not helped you.