Oracle Get SQL as a string when an exception occurs.

I am trying to return an SQL query from a database call when the query is not running and the return pointer has a failure state. This query string will be used for logging purposes.

One way to do this is to save the variable containing the SQL query as a string, then wrap each query in the PL / SQL block with an exception handler and, if an exception occurs, return the query string with a status error for the user interface component.

Is there a better way to do this? Does the exception object support Oracle or any other package?

This question seems to be a duplicate for the thread: Get the Query / CommandText that caused the SQLException

However, I did not find a solution to the problem in this thread, and I would like to know if there are any new packages supported by Oracle that give us the query string that caused the exception.

+3
source share
1 answer

When you call a database from an external language (Java, C #), you can probably do this by implementing your own JDBC driver (or something else).

You would do this by delegating the real world to a normal driver, but whenever the statement is sent to the database, you remember the statement, and if you raise an exception, you create a new exception that also includes the sql statement (and possibly bind variables )

, . , , , , , , .

+1

All Articles