Is there a advanced oracle feature to modify the SQL Query just before it is submitted to oracle? Or may be modify the result set? Based on certain condition? Like may be based on the name of the process that submits the query? Or based on the query text?
The scenario is that a process (written in C++) is running a query and we don’t have a way to change the C++ code. A particular business validation within that process is failing and in order to make the validation not fail, I want a way to manipulate the returned data set or manipulate the select query just before it is submitted to oracle engine.
The C++ code is running this exact query
SELECT PL_ID FROM A_HDR WHERE ENT_NBR=”
I want to change it such that ORACLE always sees and executes the following query instead
SELECT NULL FROM A_HDR WHERE ENT_NBR=”
Please guide
Oracle Virtual Private Database may be what you’re looking for. From the manual:
You may be able to get the process and query text from SYS_CONTEXT. For example,
sys_context('userenv', 'current_sql')andsys_context('userenv', 'module'). You may also need to useGV$SESSIONto get more information.However, I think you should try to avoid VPD if possible. It is extremely confusing to have all your SQL statements silently converted in the background. It can make development and troubleshooting very difficult.
Update
The SQL Translation Framework feature in Oracle 12c would probably be the best solution for this problem.