Skip to Main Content
  • Questions
  • Query Returns via SQL*Plus - but not via ODP.net Driver

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Mark.

Asked: July 11, 2017 - 6:50 pm UTC

Last updated: July 14, 2017 - 9:49 am UTC

Version: 11.2.0.4

Viewed 1000+ times

You Asked

We have a database with some partitioned tables (main table by value, the children by reference). We have a query that includes a function call in the where clause.

Select bunch_of_columns, package.function(parameter) as column18
from table a, table b, table c, table d
where a.key = b.key
and b.otherkey = c.key (+)
and c.key = d.key
and many_other_conditions
and package.function(parameter) = 'N'


Normally this query runs under my_app_user. In TOAD and SQLPLUS I can run this query and it returns data under both my_app_user and schema_owner_user.

BUT ... in our "application" (a .net application that uses ODP.NET) the query works for the schema_owner_user and NOT for the my_app_user.

There are no errors returned or noted.

The function does a PK based query against a view (of a relatively small table).

I should note that there are polices involved to mask some data from some users ... but have not seen a difference with policies on and off.

and Chris said...

I don't know what the issue is here. To help, we need to understand what the query is doing!

There are a few ways you can do this.

One is to trace your session then inspect the trace file. You can do this by:

exec DBMS_monitor.session_trace_enable ( null, null, true, true );
***your code here***
exec DBMS_monitor.session_trace_disable;


For more info on this read https://blogs.oracle.com/sql/how-to-create-an-execution-plan#tkprof

If you're licensed for Diagnostics and Tuning, you can use the SQL Monitor query progress and see what's happening in real time:

https://oracle-base.com/articles/11g/real-time-sql-monitoring-11gr1

Or you could look at v$active_session_history (again, if you're licensed) to see what your session has been doing recently:

http://www.oracle.com/technetwork/issue-archive/2013/13-jan/o13dba-1871177.html

Once you've got more details about what's going on, post them here and we'll see what we can do to help.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library