0

I'm having a small issue with an Oracle command, given below:

command.CommandText = "SELECT ID, NAME, RATING, LENGTH, STARTTIME FROM SCHEDULE WHERE ID=301 AND ROWNUM=1 AND SCHEDULE.STARTTIME <= SYSDATE ORDER BY STARTTIME DESC;";

It runs perfectly well in Oracle SQL Developer, returning exactly what I need, but in C#, i get the following error:

ORA-06550: line 1, column 186:
PLS-00103: Encountered the symbol "," when expecting one of the following:

. ( * @ % & = - + < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec as between || indicator multiset member
submultiset

Can anyone see any issues with it, or anything that is illegal within C#?

EDIT: Execution code:

command.Connection = conSQL;
using (IDataReader reader = command.ExecuteReader())
{
    do
    {
        int count = reader.FieldCount;
        while (reader.Read())
        {
            for (int i = 0; i < count; i++)
            {
                 string setting = reader.GetName(i).ToString();
                 object value = reader.GetValue(i);

                 ** Data assigned to variables here, hidden due to length of code**
                 ** Follows pattern: object.property(reader.name) = reader.value **
            }

        }
    } while (reader.NextResult());
 }
2
  • 1
    could you post full error? following:.....? Commented Sep 12, 2012 at 11:42
  • There has to be something going weird with the execution code. Please post the rest of the error and the entire snippet of code that's executing the command. Commented Sep 12, 2012 at 11:42

3 Answers 3

2

dot not put ; at the end of the command, that's a command line tool convention, not part of sql proper (sqlplus also uses / as terminator for instance)

Sign up to request clarification or add additional context in comments.

6 Comments

And that would cause it to say it encountered a , when parsing the statement?
@Mike: Oracle's error messages are known to be less than helpful. First thing I thought was "There's probably a trailing semi-colon on the statement" and, yep, there it was.
@BobJarvis, awesome. And now that the OP posted the rest of the error I have to be honest, my heart sunk seeing that, it hold literally no value.
@Mike: it's all about trying things and seeing what happens. I still have to believe that the ';' shouldn't be there - perhaps next to try is Skulmuk's idea of quoting the ID and NAME...
SQL is hard to parse, the syntax was defined at the height of the "natural language" fad, as a consequence locating errors is hard for the parser (Oracle is also notorious for the low quality of the error messages).
|
1

Name and Id are both special keywords in Oracle SQL. Try:

SELECT "ID", "NAME"...

3 Comments

I've tried this, and combined with Bob's advice, get ORA-00933: SQL command not properly ended
Add the ";" back to the statement and make sure that the capitilisation of your columns matches the definition as "ID" is case sensitive.
This could perhaps have been a problem, but ID and NAME are not reserved words in Oracle (thankfully, since a good portion of database tables have an ID column :)
1

Remove the trailing semi-colon on the SQL statement.

Share and enjoy.

3 Comments

And that would cause it to say it encountered a , when parsing the statement?
If I remove the trailing semi-colon, I get ORA-00933: SQL command not properly ended
@Mike: As I noted below, Oracle's messages are often unhelpful in diagnosing the actual problem. In this case the semi-colon at the end of the statement is the likely culprit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.