Problem in correlated queries

Posts   
1  /  2
 
    
arash
User
Posts: 54
Joined: 16-Dec-2008
# Posted on: 23-Dec-2009 13:56:09   

Please post back in this thread if you can confirm that other queries which previously failed now work, so I can merge the fix into the main code base.

Currently we have two nested queries using "First()" method call which were failing before this fix and they are now working fine as expected.

Thank you for your indeed quick responses and excellent support.

Regards, Arash.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 23-Dec-2009 14:10:54   

Glad your initial problem is now solved simple_smile . I'll build a release build for you and attach this to this post.

Frans Bouma | Lead developer LLBLGen Pro
arash
User
Posts: 54
Joined: 16-Dec-2008
# Posted on: 19-Jan-2010 09:40:38   

Hi, I guess the fix you applied has a side effect, so I post it here again.

I'm using "SD.LLBLGen.Pro.DQE.Oracle10g.NET20.dll" version "2.6.9.1222"

With the following query :

var count = metaData.Categories.Count();

the count is always 1 even if there are more than one records in the database, I guess the "rownum <= 1" is causing this problem in generated oracle query.

I test it with an old dll and it was working as expected.

Would you please look into it.

Thanks, Arash.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 19-Jan-2010 15:06:43   

The only solution I see is that when an aggregate function is in the projection, the original query has to be emitted, as there's no other way this will work. This thus might create an edge case where the original issue pops up (although less likely).

I'll rework the DQE code so it emits the original query if an aggregate is in the projection.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 19-Jan-2010 15:27:54   

PLease see the attached Oracle DQE. It still fixes your initial First() etc. related issue, so it doesn't fall back onto the initial erroneous code.

Frans Bouma | Lead developer LLBLGen Pro
arash
User
Posts: 54
Joined: 16-Dec-2008
# Posted on: 20-Jan-2010 09:45:29   

Yes, it works fine now. Thank you very much.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 08-Feb-2010 10:19:35   

There's another problem: with order by and group by: the limit is always on the set returned, and the WHERE clause is included in the main query so when where rownum <= x is included in the query, the orderby/groupby is applied on the limited set, while the query's intention is to limit the resulting set of the groupby/orderby.

So we've to fall back to the old scenario as well for queries which contain groupby/orderby clauses.

(ref: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=17360)

I've attached a new 2.6 build which fixes this problem.

Frans Bouma | Lead developer LLBLGen Pro
arash
User
Posts: 54
Joined: 16-Dec-2008
# Posted on: 09-Feb-2010 06:12:06   

Otis wrote:

So we've to fall back to the old scenario as well for queries which contain groupby/orderby clauses.

So, do you mean we will have the previous problem with First() in the nested query?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 09-Feb-2010 10:50:16   

arash wrote:

Otis wrote:

So we've to fall back to the old scenario as well for queries which contain groupby/orderby clauses.

So, do you mean we will have the previous problem with First() in the nested query?

Only if you supply an orderby. Which is logical, as the orderby has to be applied BEFORE the limit. Order of sql operators: from -> where -> group by -> projection -> distinct -> order by -> limit.

placing the limit inside the ordered set is therefore not correct (as the set will then always be 1 element big wink ).

It's not a problem though, as First + Orderby is the same as doing Max() or Min()

Frans Bouma | Lead developer LLBLGen Pro
arash
User
Posts: 54
Joined: 16-Dec-2008
# Posted on: 09-Feb-2010 12:19:46   

OK, Thanks.

1  /  2