简体   繁体   English

.NET ORA-01858:找到了一个非数字字符,其中包含数字

[英].NET ORA-01858: a non-numeric character was found where a numeric was expected

I am trying to construct named parameters but receive an error. 我正在尝试构造命名参数,但收到错误。

Couldn't get data from Database Oracle.DataAccess.Client.OracleException ORA-01858: a non-numeric character was found where a numeric was expected at Oracle.DataAccess.Client.OracleException.HandleErrorHelper... 无法从数据库Oracle.DataAccess.Client.OracleException ORA-01858获取数据:在Oracle.DataAccess.Client.OracleException.HandleErrorHelper中找到了数字所在的非数字字符...

private static void AddCriteria(IDbCommand command, string column, object value, string sqlOperator = "=")
{
    var parameter = command.CreateParameter();

    if (value is DateTime)
    {
        value = FormatSqlDate((DateTime)value);
    }

    parameter.ParameterName = DbHelper.GetParameterSql(parameter, "P" + (command.Parameters.Count + 1));
    parameter.Value = value;
    command.Parameters.Add(parameter);

    command.CommandText += string.Format(" {0} {1} {2} {3}", (command.Parameters.Count > 1 ? "AND" : "WHERE"), column, sqlOperator, parameter.ParameterName);
}

Following query is constructed: 以下查询构造:

SELECT *
FROM trade LEFT JOIN 
     findetail
     ON trade.trade = findetail.trade LEFT JOIN
     fintransact 
     ON findetail.fintransact = fintransact.fintransact
WHERE trade.trade = :P1 AND acctdate = :P2

While parameters are 虽然参数是

:P1 - 2298056
:P2 - TO_DATE('2014-12-31T00:00:00', 'YYYY-MM-DD"T"HH24:MI:SS')

Variables can only be values. 变量只能是值。 You cannot have a function call like TO_DATE as text in a variable. 您不能像TO_DATE这样的函数调用作为变量中的文本。

You need to put all SQL in the query text and only extract the real variables (like the actual time) into bound variables. 您需要将所有SQL放入查询文本中,并仅将实际变量(如实际时间)提取到绑定变量中。

In this case, why don't you pass a properly parsed .NET DateTime as your value? 在这种情况下,为什么不将正确解析的.NET DateTime作为值传递?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ORA-01858:在期望数字的地方找到了非数字字符? - ORA-01858: a non-numeric character was found where a numeric was expected? ORA-01858: 在需要数字的地方发现了一个非数字字符(时间戳、解码) - ORA-01858: a non-numeric character was found where a numeric was expected (timestamp, decode) 可能的日期分配错误ORA-01858:在期望数字的位置找到了非数字字符 - Possible Date assignment error ORA-01858: a non-numeric character was found where a numeric was expected ORA-01858: 在需要数字的地方发现了一个非数字字符 - ORA-01858: a non-numeric character was found where a numeric was expected ORA-01858:找到一个非数字字符,其中数字是预期的? 即使数值是数字? - ORA-01858: a non-numeric character was found where a numeric was expected? Even when the values are numbers? ORA-01858: 在一个简单的选择查询需要数字的地方发现了一个非数字字符 - ORA-01858: a non-numeric character was found where a numeric was expected for a simple select query ORA-01858:找到一个非数字字符,其中数字是预期的 - oracle 10g - ORA-01858: a non-numeric character was found where a numeric was expected - oracle 10g 看到 ORA-01858:在需要数字的地方发现了一个非数字字符 - Seeing ORA-01858: a non-numeric character was found where a numeric was expected 错误 ORA-01858:在运行查询时应为数字的位置发现了非数字字符 - Error ORA-01858: a non-numeric character was found where a numeric was expected when running query ORA-01858:找到非数字字符并期望输入数字 - ORA-01858: a non-numeric character found where a digit was expected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM