2010-07-09

ORA-38909 in Oracle 11g

Due to yesterday's question in PL/SQL Challenge I was confronted with the idea of having together 'LOG ERRORS' and 'SAVE EXCEPTIONS' in a FORALL statement.


After answering the option that I thought was the correct one (and was) and everyone in my team that plays had answered, in the end of the day we (me , A. and L.) made some testing in a 11gr2 database.
The use case would be something like this

FORALL indx IN 1 .. employee_ids.COUNT SAVE EXCEPTIONS
UPDATE (..)
LOG ERRORS REJECT LIMIT UNLIMITED;


What we found that is that it compiles and works with delete and update but with insert (we didn't test with merge but I assume that it be like insert) raises an ORA-38909 (DML Error logging is not supported with BATCH ERROR mode).

Today E. (one member of the team that was not present at that testing) found this information in a forum:

"We have run into an issue with array processing in 11g. The developer
was using execute_array and his sql statement had 'LOG ERRORS' in it.
This did not error out until we switched to 11g. The issue is that only
one is allowed, either 'LOG ERRORS' or 'SAVE EXCEPTIONS'. Our DBA
logged and error report with Oracle and after several posts back and
forth this is what they concluded,

======================================================================
After investigation and discussion, development has closed the bug as
'Not a Bug' with the following reason:

"this is an expected behavior in 11g and the user needs to specify
either of 'SAVE EXCEPTIONS' clause or the 'DML error logging', but NOT
both together.
The batch error mode, in the context of this bug, is basically referring
to the SAVE EXCEPTIONS clause.
It seems the code is trying to use both dml error logging and batch
error handling for the same insert. In that case, this is not a bug.

For INSERT, the data errors are logged in an error logging table (when
the dml error logging feature is used) or returned in batch error
handles (when using batch mode).
Since the error messages are available to the user in either case, there
is no need to both log the error in the error logging table and return
the errors in batch error handles,
and we require the user to specify one option or the other but not both
in 11G.

Both features exist in 10.x. For 11.x, users should change their
application to avoid the error.

======================================================================"


So, Oracle changed the rules! The more logical would be to give a compilation error
if both were used if that was not to be allowed! So people migrating from 10g to 11g would find that problem and fix it and not only discovering the "bug" when the system is in production (and only when that part of code was used and an exception was raised inside).

If using LOG ERRORS REJECT LIMIT UNLIMITED catches all the errors and so "SAVE EXCEPTIONS" is not needed I do not understand why the raise of the exception.

Changing a behavior not giving an error in migration and not having it described in the documentation is very bad practice from ORACLE.
Imagine that in that post people tried to turn off the "save exceptions" in the .c source :-( !!!

Even so, I can only imagine some few scenarios where people would want to use LOG ERRORS REJECT LIMIT <n> and SAVE EXCEPTIONS but I think those could be avoided.

Can you imagine (or have) a scenery where you use that?

See message translations for ORA-38909.

1 comment:

Os comentários são moderados.
The comments are moderated.