Re: Dynamically Add Error Logging To DML? VPD?

From: Stefan Koehler <contact_at_soocs.de>
Date: Tue, 12 Sep 2017 23:30:48 +0200 (CEST)
Message-ID: <1465729462.3840.1505251848922_at_ox.hosteurope.de>


Hello Jack,

> We have a COTS application that generates DML but is violating various table constraints. We can't nail down the SQL or the rows it's trying to affect. We can't edit the DML to add the "Log Errors..." line, so I was trying to figure out a way to do it dynamically.

OK, so if i get it right - all you want to do is to find the SQL and the root cause, right? This is pretty easy then - just set an event for the corresponding ORA error (e.g. ORA-00001) and create an errorstack trace (as action).

Example: SQL> alter system set events '00001 trace name errorstack level 3, lifetime 5';

All the needed information is in the errorstack trace then :)

Best Regards
Stefan Koehler

Independent Oracle performance consultant and researcher Website: http://www.soocs.de
Twitter: _at_OracleSK

> Jack Applewhite <jack.applewhite_at_austinisd.org> hat am 12. September 2017 um 23:04 geschrieben:
>
> I use DBMS_ErrLog to create logging tables a LOT and really like this feature for troubleshooting SQL. It works only if you can add the "Log Errors ..." line at the end of your DML statement. We have a COTS application that generates DML but is violating various table constraints. We can't nail down the SQL or the rows it's trying to affect. We can't edit the DML to add the "Log Errors..." line, so I was trying to figure out a way to do it dynamically.
>
> Just now I tried using VPD to add a predicate to any DML on a table and sneakily tack on the "Log Errors..." line. The policy function returns this for the predicate.
>
>   ' 1=1  Log Errors Into Reject Limit Unlimited '
>
> I thought that, since the "Log Errors..." line is always tacked on the end of the SQL, this might work. The function compiled and I created the policy, both in Sys. When I ran an Insert that I knew would violate a table constraint I got this error.
>
> SQL Error: ORA-28113: policy predicate has error
> 28113. 00000 -  "policy predicate has error"
> *Cause:    Policy function generates invalid predicate.
> *Action:   Review the trace file for detailed error information.
>
> I found the trace file in bdump and saw that VPD adds the Where, then encloses the predicate text in parentheses:
>
>       Insert .... WHERE (1 = 1  Log Errors Into Reject Limit Unlimited)
>       ORA-00907: missing right parenthesis
>
> Anyone know of a trick to get around this or other method to dynamically add the "Log Errors..." line?
>
> Thanks.

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Sep 12 2017 - 23:30:48 CEST

Original text of this message