0

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

3 回答 3

2

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

于 2012-09-12T11:43:25.557 回答
1

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

SELECT "ID", "NAME"...
于 2012-09-12T11:44:17.097 回答
1

删除 SQL 语句末尾的分号。

分享和享受。

于 2012-09-12T11:44:27.863 回答