Using the EXCEPTIONS INTO clause seems to be exhibiting
anomalous behavior.
As to the first point, was I attempting to create a picture
perfect, bullet proof general purpose data loader that was
elegant, fully self documenting and blessed by all and sundry
Oracle deities? No. Was I attempting to solve an immediate
problem as quickly as possible? Yes. Did the procedure work for
that? Yes.
As to the EXCEPTIONS clause, my understanding of an exception is
that you get a ordinal value, a "zero" case, then, when
duplicates (in the case of a primary key) are found, they are
exceptions however, as has been shown to me, Oracle treats all
occurrences, ordinal or not, as exceptions. So, Oracle is
working as programmed. Do I agree with that? No. However, it has
been that way for years. And darned of they will change it for
me, imagine that!
In the SQL Manual they have a terse:
"exceptions_clause - Specify a table into which Oracle places
the rowids of all rows violating the constraint. If you omit
schema, then Oracle assumes the exceptions table is in your own
schema. If you omit this clause altogether, then Oracle assumes
that the table is named EXCEPTIONS. The exceptions table must be
on your local database."
If you don't have an ordinal row, how can subsequent ones
violate it?
In the Administrator's guide they provide a quick overview of
the EXCEPTIONS clause with a small example. The small example (a
single violation) does show two rows being mapped in the
exceptions table. Taking some snippets from there:
"All rows that violate a constraint must be either updated or
deleted from the table containing the constraint." Which is
incorrect. What if one of the rows is the proper row? Do I
delete or update it? In the situation where there are multiple
identical rows, except for a bogus artificial key, this
statement would lead someone to believe all the rows needed to
be deleted. The section only confuses the matter more if someone
comes in with a misunderstanding about how the exception table
is populated. A second line: "When managing exceptions, the goal
is to eliminate all exceptions in your exception report table."
Also seems to indicate that every line in the exceptions table
is an exception, when there are clear cases where the line will
be a valid row, not an exception. It all ties back to the
definition of exception.
Here is the complete reference for those that doubt my veracity:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96521/general.htm#13282
If I ask, in the following series of numbers how many unique,
single digit values are there?
1,1,1,2,2,2,3,3,3,4
The answer is 4 (1,2,3,4) and 6 duplications of the numbers, not
1 (4) and 7 exceptions as Oracle's exception processing would
answer.
If you go into it with my initial understanding of what an
exception is, then the documentation seems to confirm that, if
you go into it with Oracle's understanding of an exception it
proves that. I have asked that a simple definition of what
Oracle defines an exception to be to be added if possible to the
manuals (SQL and Aministrators guide) however I am meeting with
extreme resistance.
So, the behavior noted is not a bug, just the way Oracle works.
However, you need to take this into account when dealing with
Oracle's EXCEPTIONS INTO clause. I would hate for some one
working on critical data to use the same definition of exception
I did and delete some very important data. When using the
EXCEPTIONS INTO clause, be sure to test on a test platform with
non-critical data any UPDATE or DELETE activities planned and
completely understand the outcome before applying the usage to
production data.