![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
This query returns an error: select table_name from dba_users; Error at line 1 ORA-00904: "TABLE_NAME": invalid identifier I don't have an instance to play with ATM, but does dba_users have a |
|
This query executes ( not very well but ... ): select * from dba_tables where table_name in ( select table_name from dba_users ); I believe dba_tables does have a table_name column. |
#3
| |||
| |||
|
|
A repost here from my grumpy old dba blog: inconsistent/unpredictable results make me grumpy ... Here is a strange one. Why does one query get an ORA-00904 but the same query when used as part of an IN apparently get ignored ( or not noticed as an error )? This query returns an error: select table_name from dba_users; Error at line 1 ORA-00904: "TABLE_NAME": invalid identifier This query executes ( not very well but ... ): select * from dba_tables where table_name in ( select table_name from dba_users ); This reproduces in 11.1.0.7.6 and 10.2.0.4. Is this a well known bug already or ( for some reason ) expected behavior? I am just starting to research it now ... unfortunately a developer has some bad code running in production with this type of code. |
#4
| |||
| |||
|
|
So if you use synonyms |
#5
| |||
| |||
|
| It's expected behaviour. Think correlated subqueries. If a column referenced inside a subquery does not belong to any of the tables in the subquery then Oracle assumes that it is a correlating column that comes from the next layer out. |
#6
| |||
| |||
|
|
Jonathan Lewis wrote,on my timestamp of 1/07/2011 6:23 AM: It's expected behaviour. Think correlated subqueries. If a column referenced inside a subquery does not belong to any of the tables in the subquery then Oracle assumes that it is a correlating column that comes from the next layer out. Yup, that's what I'm seeing as well. (A case of Oracle trying to be too smart for its own good?) |
#7
| |||
| |||
|
|
It's expected behaviour. Think correlated subqueries. If a column referenced inside a subquery does not belong to any of the tables in the subquery then Oracle assumes that it is a correlating column that comes from the next layer out. Yup, that's what I'm seeing as well. (A case of Oracle trying to be too smart for its own good?) No, it's standard SQL If it didn't do this, how would you write correlated subqueries ? |
#8
| |||
| |||
|
|
A repost here from my grumpy old dba blog: inconsistent/unpredictable results make me grumpy ... Here is a strange one. Why does one query get an ORA-00904 but the same query when used as part of an IN apparently get ignored ( or not noticed as an error )? This query returns an error: select table_name from dba_users; Error at line 1 ORA-00904: "TABLE_NAME": invalid identifier This query executes ( not very well but ... ): select * from dba_tables where table_name in ( select table_name from dba_users ); This reproduces in 11.1.0.7.6 and 10.2.0.4. Is this a well known bug already or ( for some reason ) expected behavior? I am just starting to research it now ... unfortunately a developer has some bad code running in production with this type of code. |
#9
| |||
| |||
|
|
A repost here from my grumpy old dba blog: inconsistent/unpredictable results make me grumpy ... Here is a strange one. Why does one query get an ORA-00904 but the same query when used as part of an IN apparently get ignored ( or not noticed as an error )? This query returns an error: select table_name from dba_users; Error at line 1 ORA-00904: "TABLE_NAME": invalid identifier This query executes ( not very well but ... ): select * from dba_tables where table_name in ( select table_name from dba_users ); |
#10
| |||
| |||
|
|
A repost here from my grumpy old dba blog: inconsistent/unpredictable results make me grumpy ... Here is a strange one. Why does one query get an ORA-00904 but the same query when used as part of an IN apparently get ignored ( or not noticed as an error )? This query returns an error: select table_name from dba_users; Error at line 1 ORA-00904: "TABLE_NAME": invalid identifier This query executes ( not very well but ... ): select * from dba_tables where table_name in ( select table_name from dba_users ); This reproduces in 11.1.0.7.6 and 10.2.0.4. Is this a well known bug already or ( for some reason ) expected behavior? I am just starting to research it now ... unfortunately a developer has some bad code running in production with this type of code. |
![]() |
| Thread Tools | |
| Display Modes | |
| |