dbTalk Databases Forums  

with clause for subquery factoring

comp.databases.oracle comp.databases.oracle


Discuss with clause for subquery factoring in the comp.databases.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
web_poster03@yahoo.com
 
Posts: n/a

Default with clause for subquery factoring - 04-04-2005 , 09:47 PM






Hi,

The following does not return result:

with free_space_by_tablespace as
( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name
select * from free_space_by_tablespace ;

BUT this does:
select * from (with free_space_by_tablespace as
( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name
select * from free_space_by_tablespace
)


What is wrong with my query?

This occurs in Sql/plus and SQL navigator v4.4.5. In MS ACCESS pass
through query, I also got the no records returned warning.

Is it due to the version problem on my client software? My Oracle
server is 9.2 and above

Thanks for any points on this.


Reply With Quote
  #2  
Old   
Mark Bole
 
Posts: n/a

Default Re: with clause for subquery factoring - 04-05-2005 , 06:17 PM






web_poster03 (AT) yahoo (DOT) com wrote:

Quote:
Hi,

The following does not return result:

with free_space_by_tablespace as
( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name
select * from free_space_by_tablespace ;

BUT this does:
select * from (with free_space_by_tablespace as
( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name
select * from free_space_by_tablespace
)


What is wrong with my query?

This occurs in Sql/plus and SQL navigator v4.4.5. In MS ACCESS pass
through query, I also got the no records returned warning.

Is it due to the version problem on my client software? My Oracle
server is 9.2 and above

Thanks for any points on this.

Missing parenthesis from first version?

oracheck (AT) binc04 (DOT) tree> with free_space_by_tablespace as
2 ( select sum(bytes)/1024 Kbytes_free,
3 max(bytes)/1024 largest,
4 tablespace_name
5 from sys.dba_free_space
6 group by tablespace_name
7 select * from free_space_by_tablespace ;
select * from free_space_by_tablespace
*
ERROR at line 7:
ORA-00907: missing right parenthesis

oracheck (AT) binc04 (DOT) tree> list
1 with free_space_by_tablespace as
2 ( select sum(bytes)/1024 Kbytes_free,
3 max(bytes)/1024 largest,
4 tablespace_name
5 from sys.dba_free_space
6 group by tablespace_name)
7* select * from free_space_by_tablespace
oracheck (AT) binc04 (DOT) tree> /

KBYTES_FREE LARGEST TABLESPACE_NAME
----------- ---------- ------------------------------
51136 51136 LOBS
768 768 MONITOR
16320 10944 SYSAUX
96512 96192 SYSTEM
153408 51136 TESTDB_A
142912 98240 UNDO01
51136 51136 USER01
34752 34752 XDB

8 rows selected.

-Mark Bole





Reply With Quote
  #3  
Old   
web_poster03@yahoo.com
 
Posts: n/a

Default Re: with clause for subquery factoring - 04-06-2005 , 09:11 AM



Thanks Mark.

After I upgrade my oracle client from 8.1.17 to 9.2 then it works.
Hope this is useful for other person

Mark Bole wrote:
Quote:
web_poster03 (AT) yahoo (DOT) com wrote:

Hi,

The following does not return result:

with free_space_by_tablespace as
( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name
select * from free_space_by_tablespace ;

BUT this does:
select * from (with free_space_by_tablespace as
( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name
select * from free_space_by_tablespace
)


What is wrong with my query?

This occurs in Sql/plus and SQL navigator v4.4.5. In MS ACCESS pass
through query, I also got the no records returned warning.

Is it due to the version problem on my client software? My Oracle
server is 9.2 and above

Thanks for any points on this.


Missing parenthesis from first version?

oracheck (AT) binc04 (DOT) tree> with free_space_by_tablespace as
2 ( select sum(bytes)/1024 Kbytes_free,
3 max(bytes)/1024 largest,
4 tablespace_name
5 from sys.dba_free_space
6 group by tablespace_name
7 select * from free_space_by_tablespace ;
select * from free_space_by_tablespace
*
ERROR at line 7:
ORA-00907: missing right parenthesis

oracheck (AT) binc04 (DOT) tree> list
1 with free_space_by_tablespace as
2 ( select sum(bytes)/1024 Kbytes_free,
3 max(bytes)/1024 largest,
4 tablespace_name
5 from sys.dba_free_space
6 group by tablespace_name)
7* select * from free_space_by_tablespace
oracheck (AT) binc04 (DOT) tree> /

KBYTES_FREE LARGEST TABLESPACE_NAME
----------- ---------- ------------------------------
51136 51136 LOBS
768 768 MONITOR
16320 10944 SYSAUX
96512 96192 SYSTEM
153408 51136 TESTDB_A
142912 98240 UNDO01
51136 51136 USER01
34752 34752 XDB

8 rows selected.

-Mark Bole


Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.