Search code examples
oraclefunctionclobora-01031ora-06512

Invalid privilege error?


Two related applications use a function in a package in several queries to return some data as CSV. The column being selected and concatenated is a CLOB field and can contain HTML, special characters, etc. The applications have few users and so are not heavily used. One is a Flex application that consumes Oracle HTTP services, and the other is an ASP.NET application that uses ODP.NET. The applications are really one integrated application with hyperlinks to each other.

Yesterday, I received several notifications of a strange error:

ORA-01031: insufficient privileges ORA-06512

The line number in the package in the error details indicates that the error was caused by the function being used in the select clause. It would occur when called by either application about 75% of the time.

Am I correct that an ORA-06512 occurred in the function that then caused an ORA-01031 insufficient privilege error? Unfortunately, ORA-06512 is a very generic error and doesn't tell me anything. And why would it cause an invalid privilege error? The Oracle user accounts being used by both applications have the execute privilege on the package that contains the function.

Regarding the function... it has been used for about 2 years in production without any issue. Also, when I imported the data to QA yesterday and tested it, no error would occur, no matter how many times I hammered the server with requests. But in production, the error would occur about 75% of the time with exactly the same parameters.

The DBA tried to help me with a trace, but we could not find the error message in the trace files.

Today, everything is back to normal in production. Even if I hammer the server with requests the error will stubbornly refuse to occur.

What caused this very strange behaviour yesterday? Do any of the gurus here have any ideas?

EDIT: I just realized one important detail. The column in the table that is being selected and concatenated into CSV by the function is a CLOB.


Solution

  • If the client applications were running "SELECT clob_to_csv(clob_col) FROM ..." and it returned an invalid privilege SOMETIMES, then it is probably something the function is trying to do, rather than the select statement not having sufficient privilege to execute the function.

    Not quite clear on what it might do that may require a privilege. Does it use a file (UTL_FILE) or network connection / web service ?

    Could be some sort of odd data (a very large clob perhaps).