我有以下内容:
$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) 我有一个有点复杂的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) 我正在从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'之后的任何事情都运行良好.
我有几千行查询,它在很长一段时间内运行良好,并在某个时候开始返回:
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)