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

B. Clay Shannon-B. Crow Raven picture B. Clay Shannon-B. Crow Raven · Apr 19, 2012 · Viewed 10.4k times · Source

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#.

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

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

...I had to change it to this for it to compile in 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).

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

Answer

Tebbe picture Tebbe · Apr 19, 2012

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.

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

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

or, using the optional AS keyword:

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

Hope this helps.