奇怪的Oracle错误

时间:2012-09-12 11:39:47

标签: c# oracle

我对Oracle命令有一个小问题,如下所示:

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

它在Oracle SQL Developer中运行得非常好,完全返回我需要的内容,但在C#中,我收到以下错误:

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

任何人都可以看到它的任何问题,或C#中的任何非法内容吗?

编辑:执行代码:

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());
 }

3 个答案:

答案 0 :(得分:2)

点不放;在命令的最后,这是一个命令行工具约定,不是sql本身的一部分(例如sqlplus也使用/作为终结符)

答案 1 :(得分:1)

Name和Id都是Oracle SQL中的特殊关键字。尝试:

SELECT "ID", "NAME"...

答案 2 :(得分:1)

删除SQL语句上的尾部分号。

分享并享受。