oracle 为什么我收到“ORA-00923: FROM 关键字未在预期位置找到”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10233048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:44:20  来源:igfitidea点击:

Why am I getting "ORA-00923: FROM keyword not found where expected"?

sqloracleora-00923

提问by B. Clay Shannon

Why is the "From" seen as being in the wrong spot?

为什么“发件人”被视为在错误的位置?

I had to change double quotes to single quotes in a query to get the query string to compile in the IDE while porting from Delphi to C#.

我不得不在查询中将双引号更改为单引号,以便在从 Delphi 移植到 C# 时在 IDE 中编译查询字符串。

IOW, with SQL like this, that works in Delphi and Toad:

IOW,使用这样的 SQL,可以在 Delphi 和 Toad 中使用:

@"SELECT R.INTERLOPERABCID "ABCID",R.INTERLOPERID "CRID", . . .

...I had to change it to this for it to compile in Visual Studio:

...我必须将其更改为这样才能在 Visual Studio 中编译:

@"SELECT R.INTERLOPERABCID 'ABCID',R.INTERLOPERID 'CRID', . . .

However, the SQL won't run that way - I get the "ORA-00923: FROM keyword not found where expected" err msg (both in Toad and when trying to execute the SQL in the C# app).

但是,SQL 不会以这种方式运行 - 我收到“ORA-00923:FROM 关键字未在预期位置找到”错误消息(在 Toad 和尝试在 C# 应用程序中执行 SQL 时)。

How can I get it both to compile and to run?

我怎样才能让它编译和运行?

回答by Tebbe

The quotes around your column aliases are giving it heartburn.

列别名周围的引号引起了它的胃灼热。

It appears that in the original case, the entire query is surrounded by double quotes, and the double quotes around the column aliases mess with those.

看起来在原始情况下,整个查询被双引号包围,列别名周围的双引号与这些混淆。

In the second case, Oracle is interpreting the single-quoted column aliases as strings, which throw it off.

在第二种情况下,Oracle 将单引号列别名解释为字符串,从而将其丢弃。

In Oracle, you shouldn't need either: You should be able to just code:

在 Oracle 中,您不应该需要:您应该能够只编码:

@"SELECT R.INTERLOPERABCID ABCID,R.INTERLOPERID CRID, . . .

or, using the optional ASkeyword:

或者,使用可选AS关键字:

@"SELECT R.INTERLOPERABCID AS ABCID,R.INTERLOPERID AS CRID, . . .

Hope this helps.

希望这可以帮助。

回答by NEO

It is generally don't work if you have inline comments in query

如果您在查询中有内联注释,则通常不起作用