【问题标题】:PHP / OCI Invalid Character during insert插入期间PHP / OCI无效字符
【发布时间】:2014-11-25 22:30:00
【问题描述】:

我正在尝试在 PHP 页面上执行 Oracle 插入语句,但出现以下错误。如果我从语句中删除分号,则页面永远不会加载(即使后端的插入需要几分之一秒)。任何提示将不胜感激!

$sql_update = "
update schema.table set last_check_dt = (select sysdate from dual)
where id = (select id from schema.email where current_email = '" . $email . "');";

$stid = oci_parse($conn, $sql_update);
oci_execute($stid); 
oci_commit($conn);
oci_close($conn);

Warning: oci_execute() [function.oci-execute]: ORA-00911: invalid character 

【问题讨论】:

  • 要检查的三件事:分号没用但应该不是问题,您的 set 元素中的子查询很奇怪,是问题吗?此外,使用“id IN (SELECT....” 您的最后一个子查询会更好
  • @nek 子查询问题,我同意你的说法,但最终会出现不同的错误,而不是无效字符..
  • 分号在这里看起来像一个错误的字符,这是对错误的最佳解释。 = 后面的 ( 更像是“token =”后面的解析错误。

标签: php oracle oracle-call-interface


【解决方案1】:
$sql_update = "
update schema.table set last_check_dt = (select sysdate from dual)
where id = (select id from schema.email where current_email = '" . $email . "')";

您的 SQL 在运行时通过 OCI.. 不需要 semicolon 作为终止符。

【讨论】:

  • 谢谢 - 但由于某些原因,该 SQL 页面将不再加载。它计时但没有任何反应。
  • 你的桌子上有锁吗?它可能会无限期地等待,直到锁被释放。
  • 哇!它碰巧是一把锁,我真的很怀疑,但是还有另一个窗口打开了运行未提交的查询......这让我发疯了。谢谢你
猜你喜欢
  • 2013-05-23
  • 2016-03-03
  • 1970-01-01
  • 1970-01-01
  • 2020-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多