0

I am executing the following query:

explain plan for  
with Foo   
as (  
     select * from my_table 
   )  
select * from Foo  
where x = 7;

This results in an invalid SQL statement exception in Oracle10g. Without the explain plan the with statement executes correctly. Why does this error occur within the context of SQL Developer?

Woot4Moo
  • 23,987
  • 16
  • 94
  • 151

2 Answers2

1

You have an extra parentheses:

explain plan for  
with Foo   
as (  
     select * from my_table)  -- < remove this
   )  
select * from Foo  
where x = 7;
Taryn
  • 242,637
  • 56
  • 362
  • 405
0

Not sure about this nuance but there is another way to write that will explain.

Select *
  From (
        Select * From my_table
       ) Foo
 Where Foo.x = 7;

I stay away from with clauses because they don't port well and in my experience don't get evaulated by the optimizer as well as dynamic from clauses, but those are older experiences.