Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle SQL Syntax: With clause

I'm currently using the Java Version of General SQL Parser for Oracle for some relatively complex Oracle SQL Queries.

As in my case I have no access to any Oracle DB but only have the SQL statements in a file I encounter some statements where the parser fails, one particular boils down to following.

select id from (
with foo as (
    select bar from sometable
)
select *
from foo
)

The with clause can be parsed without problem, if not nested.

with foo as (
    select bar from sometable
)
select *
from foo

So do I have a bug in the parser or in the statement?

Best, Will

like image 370
Will Avatar asked Mar 14 '26 02:03

Will


2 Answers

The SQL statement is valid, so I guess the parser just can't handle it.

To be sure, try running the SQL in SQL Plus.

like image 192
Tony Andrews Avatar answered Mar 16 '26 18:03

Tony Andrews


This is a perfectly valid statement in Oracle (I just tried it).
But it might not be valid ANSI SQL and that might be the reason why the parser doesn't understand it.

like image 39
Daniel Hilgarth Avatar answered Mar 16 '26 19:03

Daniel Hilgarth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!