问题“ORA-01722:无效号码”很多地方都出现了错误

发布于 2024-11-25 09:41:51 字数 958 浏览 1 评论 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).

I am getting error "ORA-01722: invalid number" at many places with Oracle driver. Can you point out the workaround/solution?

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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏见 2024-12-02 09:41:51

没有上下文,我们很难确定。但我处于猜测的状态,所以这里是:

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

另外,当然,我还是在猜测你的问题:-)

Without context, it is hard for us to be sure. But I'm in a guessing mood, so here goes:

base.fid is a numeric column. In :db_condition_placeholder_0 you are attempt to pass a string of tokens such as "23, 42, 69".

Now what you're hoping is that the SQL engine will munge that together to produce a line like this:

where base.fid in (23, 42, 69)

Alas, what it actually generates is this:

where base.fid in ('23, 42, 69')

... which logically is the same as:

where base.fid = to_number('23, 42, 69')

Obviously the string isn't a valid number and hence the ORA-1722.

Now what you do about it is a tricky matter. There are several different approaches, including nested tables or arrays, pipelined functions and dynamic SQL. Which one will suit you best depends on the details of your requirement.

Plus, of course, I'm guessing about your problem anyway :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文