标签: ora-01858

oci_bind_by_name和to_date PHP/OCI/Oracle

我有以下内容:

    $ARTIFACT_NAME = $_POST['ArtifactName'];
    $ARTIFACT_TYPE = $_POST['ArtifactType'];
    $ARTIFACT_LOCATION = $_POST['ArtifactLocation'];
    $ARTIFACT_DOMAIN = $_POST['ArtifactDomain'];
    $ARTIFACT_AUTHOR = $_POST['ArtifactAuthor'];
    $ARTIFACT_LABEL = 'DB_'.$ARTIFACT_LOCATION.'_'.$ARTIFACT_DOMAIN.'_'.$ARTIFACT_NAME;
    $AUDIT_CONSTRAINTS = $_POST['AuditConstraints'];
    $SECURITY_CONSTRAINTS = $_POST['SecurityConstraints'];
    $REGISTERED_EMAIL = $_SERVER['HTTP_REMOTE_USER'];
    $REGISTERED_TIMESTAMP = "to_date('15-08-2011 14:32:37', 'DD-MM-YYYY HH24:MI:SS')";

    $query =    "INSERT INTO ".$db_schema.".ARTIFACTS (ARTIFACT_ID, ARTIFACT_NAME, ARTIFACT_TYPE, ARTIFACT_LOCATION, ARTIFACT_DOMAIN, ARTIFACT_AUTHOR, ARTIFACT_LABEL, AUDIT_CONSTRAINTS, SECURITY_CONSTRAINTS, REGISTERED_EMAIL, REGISTERED_TIMESTAMP)
                VALUES (:bind1, :bind2, :bind3, :bind4, :bind5, :bind6, :bind7, :bind8, :bind9, :bind10, :bind11)";
    $statement = oci_parse($connection, $query);

    oci_bind_by_name($statement, ":bind1", $ARTIFACT_ID);
    oci_bind_by_name($statement, ":bind2", $ARTIFACT_NAME);
    oci_bind_by_name($statement, ":bind3", $ARTIFACT_TYPE);
    oci_bind_by_name($statement, ":bind4", $ARTIFACT_LOCATION);
    oci_bind_by_name($statement, ":bind5", …
Run Code Online (Sandbox Code Playgroud)

php oracle oracle-call-interface ora-01858

7
推荐指数
1
解决办法
8915
查看次数

奇怪的Oracle行为:WHERE子句中的TO_DATE和CONCAT

我有一个有点复杂的SQL查询,它从发票表中提取.要查询的表使用三个数字字段来创建日期(一个用于日,月和年).

此查询使用TO_DATE函数内部的concat函数调用的组合.在查询的SELECT部分​​没有问题,但是当我在WHERE子句中使用相同的语句时,我得到一个"ORA-01858:找到一个非数字字符,其中一个数字是预期的",指的是第一个在WHERE子句中使用TO_DATE内的concat.

那么,在where子句中使用concat和TO_DATE有什么不同呢?

例如,WHERE的以下部分导致非数字字符错误

to_date(
  concat(invoice_year,
  concat('-',
  concat(invoice_month, 
  concat('-',invoice_day)))),'YYYY-MM-DD')
  > add_months(sysdate,-6)
Run Code Online (Sandbox Code Playgroud)

但是select中的这个语句评估得很好

to_date(
  concat(invoice_year,
  concat('-',
  concat(invoice_month,
  concat('-',invoice_day)))),'YYYY-MM-DD') as invoice_date
Run Code Online (Sandbox Code Playgroud)

sql oracle date oracle10g ora-01858

4
推荐指数
1
解决办法
1568
查看次数

Oracle不接受2000年之前的日期

我正在从C#.NET应用程序插入Oracle数据库.失败的查询看起来像:

INSERT INTO staging (create_date) VALUES ('16-Nov-1999')
Run Code Online (Sandbox Code Playgroud)

当我从SQL Navigator运行它时,运行正常.通过.NET,数据库抛出:

ORA-01858: a non-numeric character was found where a numeric was expected
Run Code Online (Sandbox Code Playgroud)

我运行了一些测试用例并确认是导致异常的一年.'31 -Dec-1999'之后的任何事情都运行良好.

.net sql oracle oledb ora-01858

2
推荐指数
1
解决办法
392
查看次数

如果日期不是日期格式,则返回 null

我有几千行查询,它在很长一段时间内运行良好,并在某个时候开始返回:

ORA-01858: a non-numeric character was found where a numeric was expected
01858. 00000 -  "a non-numeric character was found where a numeric was expected"
*Cause:    The input data to be converted using a date format model was
           incorrect.  The input data did not contain a number where a number was
           required by the format model.
*Action:   Fix the input data or the date format model to make sure the
           elements match in number and type.  Then retry the operation. …
Run Code Online (Sandbox Code Playgroud)

sql oracle date ora-01858

0
推荐指数
1
解决办法
686
查看次数

标签 统计

ora-01858 ×4

oracle ×4

sql ×3

date ×2

.net ×1

oledb ×1

oracle-call-interface ×1

oracle10g ×1

php ×1