我在使用Oracle驱动程序的许多地方收到错误“ORA-01722:无效数字”。你能指出解决方法/解决方案吗?
PDOException: SELECT base.fid AS fid, base.uid AS uid,
base.filename AS filename, base.uri AS uri, base.filemime AS filemime,
base.filesize AS filesize, base.status AS status, base.timestamp AS timestamp
FROM {file_managed} base
WHERE (base.fid IN (:db_condition_placeholder_0))
(prepared: SELECT base.fid AS fid, base."UID" AS "UID",
base.filename AS filename, base.uri AS uri, base.filemime AS filemime,
base.filesize AS filesize, base.status AS status, base.timestamp AS timestamp
FROM "FILE_MANAGED" base
WHERE (base.fid IN (:db_condition_placeholder_0))
)
e: SQLSTATE[HY000]: General error: 1722
OCIStmtExecute: ORA-01722: invalid number (ext\pdo_oci\oci_statement.c:146)
args: Array ( [:db_condition_placeholder_0] => )
in DrupalDefaultEntityController->load()
(line 196 of C:\xampp\htdocs\new\drupal\includes\entity.inc).
答案 0 :(得分:3)
没有背景,我们很难确定。但我有一种猜测的心情,所以这里有:
base.fid
是一个数字列。在:db_condition_placeholder_0
中,您尝试传递一系列令牌,例如"23, 42, 69"
。
现在您希望SQL引擎能够将它们组合在一起以产生这样的一行:
where base.fid in (23, 42, 69)
唉,它实际产生的是:
where base.fid in ('23, 42, 69')
......在逻辑上与以下相同:
where base.fid = to_number('23, 42, 69')
显然字符串不是有效数字,因此是ORA-1722。
现在你做的是一件棘手的事情。有几种不同的方法,包括嵌套表或数组,流水线函数和动态SQL。哪一个最适合您,取决于您的要求的细节。
另外,当然,无论如何,我猜测你的问题: - )