![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Interestingly 8.0.2.4301 executes this statement: select PersonID from xxxcand where xxxcand.consno in (select consno from xxxconsxref where region = 'M') and personid is not null; without error even though there is no consno field in xxxconsxref. (there is one in xxxcand, but its not a correlated subquery). If you execute select consno from xxxconsxref where region = 'M' by itself you get the appropiate error message. The query behaves as though the xxxcand.consno in (select consno from xxxconsxref where region = 'M') clause was not present! Justin Willey |
#3
| |||
| |||
|
|
Its reproducable here. We logged bug QTS 341445 for this problem. -- Hartmut Branz International and Sustaining Engineering iAnywhere Solutions Justin Willey wrote: Interestingly 8.0.2.4301 executes this statement: select PersonID from xxxcand where xxxcand.consno in (select consno from xxxconsxref where region = 'M') and personid is not null; without error even though there is no consno field in xxxconsxref. (there is one in xxxcand, but its not a correlated subquery). If you execute select consno from xxxconsxref where region = 'M' by itself you get the appropiate error message. The query behaves as though the xxxcand.consno in (select consno from xxxconsxref where region = 'M') clause was not present! Justin Willey |
#4
| |||
| |||
|
|
Interestingly 8.0.2.4301 executes this statement: select PersonID from xxxcand where xxxcand.consno in (select consno from xxxconsxref where region = 'M') and personid is not null; without error even though there is no consno field in xxxconsxref. (there is one in xxxcand, but its not a correlated subquery). If you execute select consno from xxxconsxref where region = 'M' by itself you get the appropiate error message. The query behaves as though the xxxcand.consno in (select consno from xxxconsxref where region = 'M') clause was not present! Justin Willey |
#5
| |||
| |||
|
|
I don't see what the problem is here. It is perfectly valid to place the unqualified column name "consno" in the select list of the subquery (which does make the subquery correlated). The subquery predicate will return true as long there exists at least one row in xxconsxref where region = 'M'. If there is no such row, the subquery will consist of the empty set, so that the predicate xxxcand.consno in ( <subquery> ) will evaluate to UNKNOWN which will then be interpreted as FALSE. Glenn Justin Willey wrote: Interestingly 8.0.2.4301 executes this statement: select PersonID from xxxcand where xxxcand.consno in (select consno from xxxconsxref where region = 'M') and personid is not null; without error even though there is no consno field in xxxconsxref. (there is one in xxxcand, but its not a correlated subquery). If you execute select consno from xxxconsxref where region = 'M' by itself you get the appropiate error message. The query behaves as though the xxxcand.consno in (select consno from xxxconsxref where region = 'M') clause was not present! Justin Willey |
#6
| |||
| |||
|
|
I don't see what the problem is here. It is perfectly valid to place the unqualified column name "consno" in the select list of the subquery (which does make the subquery correlated). The subquery predicate will return true as long there exists at least one row in xxconsxref where region = 'M'. If there is no such row, the subquery will consist of the empty set, so that the predicate xxxcand.consno in ( <subquery> ) will evaluate to UNKNOWN which will then be interpreted as FALSE. Glenn Justin Willey wrote: Interestingly 8.0.2.4301 executes this statement: select PersonID from xxxcand where xxxcand.consno in (select consno from xxxconsxref where region = 'M') and personid is not null; without error even though there is no consno field in xxxconsxref. (there is one in xxxcand, but its not a correlated subquery). If you execute select consno from xxxconsxref where region = 'M' by itself you get the appropiate error message. The query behaves as though the xxxcand.consno in (select consno from xxxconsxref where region = 'M') clause was not present! Justin Willey -- Glenn Paulley Research and Development Manager, Query Processing iAnywhere Solutions Engineering EBF's and Patches: http://downloads.sybase.com choose SQL Anywhere Studio >> change 'time frame' to all To Submit Bug Reports: http://casexpress.sybase.com/cx/cx.stm SQL Anywhere Studio Supported Platforms and Support Status http://my.sybase.com/detail?id=1002288 Whitepapers, TechDocs, and bug fixes are all available through the iAnywhere Developer Community at www.ianywhere.com/developer |
#7
| |||
| |||
|
|
Ohhhhhh, man, that is so *evil*... I, too, would have bet good money it was a bug. But nooooooo, it's standard ANSI SQL, isn't it? This would be a good time to reaffirm the rule, "always qualify column names." |
#8
| |||
| |||
|
|
I see your point about the sub query in fact being correlated and therefore if there is no consno column in xxxconsxref the engine assumes you're talking about xxxcand.cosno. Interestingly though if you add the column consno to xxxconsxref the query executes and you don't get a 'Ambiguous column name error'. This suggests that there is an order in which the engine looks for the columns in the tables in the queries, which could presumably change depending on how the optimiser restructures the query. Justin Willey "Glenn Paulley" <paulley (AT) ianywhere (DOT) com> wrote in message news:3fd09f50$1 (AT) forums-1-dub (DOT) .. I don't see what the problem is here. It is perfectly valid to place the unqualified column name "consno" in the select list of the subquery (which does make the subquery correlated). The subquery predicate will return true as long there exists at least one row in xxconsxref where region = 'M'. If there is no such row, the subquery will consist of the empty set, so that the predicate xxxcand.consno in ( <subquery> ) will evaluate to UNKNOWN which will then be interpreted as FALSE. Glenn Justin Willey wrote: Interestingly 8.0.2.4301 executes this statement: select PersonID from xxxcand where xxxcand.consno in (select consno from xxxconsxref where region = 'M') and personid is not null; without error even though there is no consno field in xxxconsxref. (there is one in xxxcand, but its not a correlated subquery). If you execute select consno from xxxconsxref where region = 'M' by itself you get the appropiate error message. The query behaves as though the xxxcand.consno in (select consno from xxxconsxref where region = 'M') clause was not present! Justin Willey -- Glenn Paulley Research and Development Manager, Query Processing iAnywhere Solutions Engineering EBF's and Patches: http://downloads.sybase.com choose SQL Anywhere Studio >> change 'time frame' to all To Submit Bug Reports: http://casexpress.sybase.com/cx/cx.stm SQL Anywhere Studio Supported Platforms and Support Status http://my.sybase.com/detail?id=1002288 Whitepapers, TechDocs, and bug fixes are all available through the iAnywhere Developer Community at www.ianywhere.com/developer |
![]() |
| Thread Tools | |
| Display Modes | |
| |