Oracle SQL 语法:With 子句
我目前正在使用 Java 版本的 General SQL Parser for Oracle 来处理一些相对复杂的 Oracle SQL 查询。
在我的例子中,我无法访问任何 Oracle DB,但只有文件中的 SQL 语句,我遇到了一些解析器失败的语句,一个具体情况可归结为以下情况。
select id from (
with foo as (
select bar from sometable
)
select *
from foo
)
如果没有嵌套,则可以毫无问题地解析 with 子句。
with foo as (
select bar from sometable
)
select *
from foo
那么我的解析器或语句中是否有错误?
最好的, 将要
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SQL 语句是有效的,所以我猜解析器无法处理它。
为确保安全,请尝试在 SQL Plus 中运行 SQL。
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.
这是 Oracle 中完全有效的语句(我刚刚尝试过)。
但它可能不是有效的 ANSI SQL,这可能是解析器不理解它的原因。
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.