PC Review


Reply
Thread Tools Rate Thread

DataAdapter retrieves no row from Oracle left join count query

 
 
tonixlaw@yahoo.ca
Guest
Posts: n/a
 
      21st Jul 2005
Hi guys,

In vb.net, i use OracleDataAdapter to execute following query and fill
into a DataSet. The problem is it returns no row but actually it should
have some rows. If you run this query in sql plus or similiar tool, it
works fine. This problem happens only when the first table has rows
that the second table can not match, under normal circumstance this
query should return some rows with f2 = 0.

select ta.id, count(tb.id) as f2
from ta left join tb
on ta.id = tb.id
group by ta.id

So if you change "left join" into "inner join", it works fine. I highly
suspect this is a bug of the .NET client provider for oracle.

Currently my workaround is making an ugly query like this:

select ta.id, count(tb.id) as f2
from ta INNER join tb
on ta.id = tb.id
group by ta.id
UNION
select ta.id, 0 as f2
from ta
where not exists
(select * from tb
where ta.id = tb.id)

I am using Oracle 9i.

Anyone has similiar experience or some idea on solving this problem?
Thanks.

Tonix

 
Reply With Quote
 
 
 
 
W.G. Ryan MVP
Guest
Posts: n/a
 
      21st Jul 2005
Tony - are you specifying any parameters in this query?
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi guys,
>
> In vb.net, i use OracleDataAdapter to execute following query and fill
> into a DataSet. The problem is it returns no row but actually it should
> have some rows. If you run this query in sql plus or similiar tool, it
> works fine. This problem happens only when the first table has rows
> that the second table can not match, under normal circumstance this
> query should return some rows with f2 = 0.
>
> select ta.id, count(tb.id) as f2
> from ta left join tb
> on ta.id = tb.id
> group by ta.id
>
> So if you change "left join" into "inner join", it works fine. I highly
> suspect this is a bug of the .NET client provider for oracle.
>
> Currently my workaround is making an ugly query like this:
>
> select ta.id, count(tb.id) as f2
> from ta INNER join tb
> on ta.id = tb.id
> group by ta.id
> UNION
> select ta.id, 0 as f2
> from ta
> where not exists
> (select * from tb
> where ta.id = tb.id)
>
> I am using Oracle 9i.
>
> Anyone has similiar experience or some idea on solving this problem?
> Thanks.
>
> Tonix
>



 
Reply With Quote
 
tonixlaw@yahoo.ca
Guest
Posts: n/a
 
      21st Jul 2005
No parameter.

 
Reply With Quote
 
Sahil Malik [MVP]
Guest
Posts: n/a
 
      25th Jul 2005
What results do you get when you try executing the queries below through
SQL+?

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
----------------------------------------------------------------------------

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi guys,
>
> In vb.net, i use OracleDataAdapter to execute following query and fill
> into a DataSet. The problem is it returns no row but actually it should
> have some rows. If you run this query in sql plus or similiar tool, it
> works fine. This problem happens only when the first table has rows
> that the second table can not match, under normal circumstance this
> query should return some rows with f2 = 0.
>
> select ta.id, count(tb.id) as f2
> from ta left join tb
> on ta.id = tb.id
> group by ta.id
>
> So if you change "left join" into "inner join", it works fine. I highly
> suspect this is a bug of the .NET client provider for oracle.
>
> Currently my workaround is making an ugly query like this:
>
> select ta.id, count(tb.id) as f2
> from ta INNER join tb
> on ta.id = tb.id
> group by ta.id
> UNION
> select ta.id, 0 as f2
> from ta
> where not exists
> (select * from tb
> where ta.id = tb.id)
>
> I am using Oracle 9i.
>
> Anyone has similiar experience or some idea on solving this problem?
> Thanks.
>
> Tonix
>



 
Reply With Quote
 
tonixlaw@yahoo.ca
Guest
Posts: n/a
 
      29th Jul 2005
Through SQL+, it's normal.

Tonix

 
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
Oracle sequence retrieves old value =?iso-8859-1?q?Norbert_P=FCrringer?= Microsoft ADO .NET 0 12th Sep 2007 11:45 AM
Left Join, Inner Join Nested Query =?Utf-8?B?TGlsTW9yZVBsZWFzZQ==?= Microsoft Access Queries 3 3rd Nov 2006 07:31 PM
#Error in result set with query containing table and left join to another query bu Microsoft Access 0 6th Apr 2005 09:48 PM
Left Join to show a count of zero Carlene Microsoft Access Queries 1 25th Nov 2003 12:30 PM
Excel retrieves data from Oracle Patrick Molloy Microsoft Excel Programming 1 29th Aug 2003 08:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:30 AM.