PC Review


Reply
Thread Tools Rate Thread

REF CURSOR returns no rows

 
 
MW
Guest
Posts: n/a
 
      17th Mar 2004
Dear All,

I am having a really strange problem with reading cursors from an Oracle 9i
database for a "particular" procedure. My DataReader does not contain any
rows after I execute the command object. I have tried

cmd.ExecuteReader

and

x = DataAdaptor(cmd)
x.Fill(myDataSet)

I execute the SELECT statement in TOAD/ SQL PLUS and that works fine. The
SELECT statement is a bit complex with lots of outer joins. If I replace it
with a more simple select statement, the procedure executes properly and the
datareader is populated

I then converted the procedure into a function returning the cursor and
executed it on SQL Plus to test if the REFCURSOR is returning empty handed,
such that

var results refcursor
exec :results := PackageName.getAllOrders(ContactId);
print results;

And again I see the output in SQL Plus. Why this is not reflecting in the
DataReader is driving me crazy. The complex SQL has 13 joins (very neccesary
given the nature of the legecy database I am working with). The problem is
also not in the way I am handling the .NET code because the .NET
function/stored procedure works with a simpler SELECT statement. I have
other stored procedures defined similairly that work properly . I have also
followed the MSDN examples to see of there is any difference. There is none.

Is there any limitations in returning complex selects in a REF CURSOR?
Any idea would be greatly appreciated.

Many thanks,
Wazir












 
Reply With Quote
 
 
 
 
David Browne
Guest
Posts: n/a
 
      17th Mar 2004

"MW" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Dear All,
>
> I am having a really strange problem with reading cursors from an Oracle

9i
> database for a "particular" procedure. My DataReader does not contain any
> rows after I execute the command object. I have tried
>
> cmd.ExecuteReader
>
> and
>
> x = DataAdaptor(cmd)
> x.Fill(myDataSet)
>
> I execute the SELECT statement in TOAD/ SQL PLUS and that works fine. The
> SELECT statement is a bit complex with lots of outer joins. If I replace

it
> with a more simple select statement, the procedure executes properly and

the
> datareader is populated
>
> I then converted the procedure into a function returning the cursor and
> executed it on SQL Plus to test if the REFCURSOR is returning empty

handed,
> such that
>
> var results refcursor
> exec :results := PackageName.getAllOrders(ContactId);
> print results;
>
> And again I see the output in SQL Plus. Why this is not reflecting in the
> DataReader is driving me crazy. The complex SQL has 13 joins (very

neccesary
> given the nature of the legecy database I am working with). The problem is
> also not in the way I am handling the .NET code because the .NET
> function/stored procedure works with a simpler SELECT statement. I have
> other stored procedures defined similairly that work properly . I have

also
> followed the MSDN examples to see of there is any difference. There is

none.
>
> Is there any limitations in returning complex selects in a REF CURSOR?
> Any idea would be greatly appreciated.
>




What happens if you use a CommandText of

begin :results := PackageName.getAllOrders(:ContactId); end;

and bind an output OracleRefCursor and and input ContactId%TYPE parameter?

What version of ODP.NET and the Oracle Client are you using?
Update those and if the problem persists post a repro to the ODP.NET forum
at Oracle.

http://forums.oracle.com/forums/foru...rt=0&forum=146

David


 
Reply With Quote
 
MW
Guest
Posts: n/a
 
      17th Mar 2004
I am using MS .NET Framework Data Provider for Oracle version 1.0.1012.0
(System.Data.OracleClient.dll) and Oracle9i Enterprise Edition Release
9.2.0.4.0.

Thank you for your response. Since my procedure was working for simpler
SELECT statements, I built its complexity slowly testing the resultset in
..NET each time. It seems to me that when I do a MAX from one of the lower
tables, the resultset returns empty-handed. I have modifed my query to
include a nested table and derive my MAX column from it and its working now.
Although I am not sure why it did not work before. It still puzzles me a
great deal.

I dont have an OracleRefCursor object available. Is this a part of the Data
Provider from Oracle? Is there any website that can give me a comparitive
chart between the two providers?

Thanks once again,
Wazir


 
Reply With Quote
 
David Browne
Guest
Posts: n/a
 
      17th Mar 2004

"MW" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I am using MS .NET Framework Data Provider for Oracle version 1.0.1012.0
> (System.Data.OracleClient.dll) and Oracle9i Enterprise Edition Release
> 9.2.0.4.0.
>
> Thank you for your response. Since my procedure was working for simpler
> SELECT statements, I built its complexity slowly testing the resultset in
> .NET each time. It seems to me that when I do a MAX from one of the lower
> tables, the resultset returns empty-handed. I have modifed my query to
> include a nested table and derive my MAX column from it and its working

now.
> Although I am not sure why it did not work before. It still puzzles me a
> great deal.
>
> I dont have an OracleRefCursor object available. Is this a part of the

Data
> Provider from Oracle?


Yes.
>Is there any website that can give me a comparitive
> chart between the two providers?


Not that I know of, but they are very very similar. ODP.NET gives you
access to more cool Oracle features like Array Binding, PL/SQL tables, and
Oracle XML. Plus it supports multiple ref cursors, and has better support
than the MS driver.

Go to http://otn.oracle.com/tech/windows/odpnet/index.html and get ODP.NET.
The install includes the 9i version of the Oracle Client, which is likely
where your error is occuring.

David


 
Reply With Quote
 
MW
Guest
Posts: n/a
 
      17th Mar 2004
Many thanks David


 
Reply With Quote
 
Marcel Sottnik
Guest
Posts: n/a
 
      23rd Mar 2004
Hallo

I noticed this strange behaviour too. But in my case it had nothing to do
with stored procedure, it was a direct select put as statement in the
command text.

I found out following things:

1. Empty result set comes if there is an aggregate function in the column
list of select which has to process NULL values and its result is NULL
value.
2. I tried following Oracle .NET providers: OraDirect from CoreLabs, Oracle
9.2.04, ComponentOne, original Microsoft Oracle .NET provider. All of them
except Microsoft returns in this case empty result set. The Microsoft's
Oracle .NET provider produces correct output.

I could not find out why does it work only with MS's Oracle data provider.


"MW" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Dear All,
>
> I am having a really strange problem with reading cursors from an Oracle

9i
> database for a "particular" procedure. My DataReader does not contain any
> rows after I execute the command object. I have tried
>
> cmd.ExecuteReader
>
> and
>
> x = DataAdaptor(cmd)
> x.Fill(myDataSet)
>
> I execute the SELECT statement in TOAD/ SQL PLUS and that works fine. The
> SELECT statement is a bit complex with lots of outer joins. If I replace

it
> with a more simple select statement, the procedure executes properly and

the
> datareader is populated
>
> I then converted the procedure into a function returning the cursor and
> executed it on SQL Plus to test if the REFCURSOR is returning empty

handed,
> such that
>
> var results refcursor
> exec :results := PackageName.getAllOrders(ContactId);
> print results;
>
> And again I see the output in SQL Plus. Why this is not reflecting in the
> DataReader is driving me crazy. The complex SQL has 13 joins (very

neccesary
> given the nature of the legecy database I am working with). The problem is
> also not in the way I am handling the .NET code because the .NET
> function/stored procedure works with a simpler SELECT statement. I have
> other stored procedures defined similairly that work properly . I have

also
> followed the MSDN examples to see of there is any difference. There is

none.
>
> Is there any limitations in returning complex selects in a REF CURSOR?
> Any idea would be greatly appreciated.
>
> Many thanks,
> Wazir
>
>
>
>
>
>
>
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: when typing the cursor always returns somewhere along the sentence Jezebel Microsoft Word Document Management 0 10th Jan 2007 10:14 PM
when typing the cursor returns somewhere along sentence =?Utf-8?B?c2xvd2FuZGdlbnRsZTI1?= Microsoft Word Document Management 1 10th Jan 2007 08:28 PM
how do i move the cursor in a document w/o entering returns? =?Utf-8?B?Q2FseXBzb1Zpb2xldA==?= Microsoft Word Document Management 1 21st Dec 2006 06:00 AM
How do you call a stored procedure that returns a cursor? Burak Microsoft ADO .NET 2 21st Jul 2004 02:42 PM
Example of using a stored procedure that returns a cursor George Microsoft ASP .NET 2 14th Jan 2004 03:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:37 PM.