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

Go To StackoverFlow.com

1

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?

2012-04-19 16:58
by B. Clay Shannon
can we see the line with the 'from' placement - KevinDTimm 2012-04-19 16:59
I can avoid the problem by removing the column aliases, which in this case I don't need - but what when I do/when somebody does - B. Clay Shannon 2012-04-19 17:10
@Kevin: . . . W.INTERLOPERTYPE, W.OFFICEDIVISION FROM RTINTERLOPERSTAT R, ABCWORKER - B. Clay Shannon 2012-04-19 17:11
What's this @" prefix? That sure isn't valid SQL - a_horse_with_no_name 2012-04-19 17:19
No, it's for C# - so that I can spread the lines of SQL over several lines in the editor without working about concatenating strings. IOW, what I just wrote (above) would cause a compilation error if I added it to: String s = " but if added it to String s = @" it would be okay - B. Clay Shannon 2012-04-19 17:34
PLease do not use implict syntax, that is a SQl antipattern and a very bad habit - HLGEM 2012-04-19 18:59


5

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.

2012-04-19 17:17
by Tebbe


1

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

2015-06-26 18:34
by NEO
Ads