0

使用 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).
4

1 回答 1

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。哪一个最适合您取决于您​​的要求的详细信息。

另外,当然,无论如何我都在猜测您的问题:-)

于 2011-07-21T10:43:56.377 回答