我正在尝试以与插入相同的方式更新(C)LOB。 (插入已经在工作)。
$queryHandle = oci_parse($dbHandle, "update MYTABLE set "MYCLOB" = EMPTY_CLOB() , "OTHERCOL" = :col0 where "PKIDCOL" = :wherecol0 returning "OTHERCOL" , "MYCLOB", into :retcol0 , :retcol1");
if(!is_resource($queryHandle)) {
$error=oci_error($dbHandle);
die($error['message'], $error['code']);
}
oci_bind_by_name($queryHandle, ":col0", $othercolvalue);
oci_bind_by_name($queryHandle, ":wherecol0", $pkidcol);
oci_bind_by_name($queryHandle, ":retcol0", $retcol1, 100);
$lob=oci_new_descriptor($dbHandle);
oci_bind_by_name($queryHandle, ":retcol1", $lob, -1, SQLT_CLOB);
if(!oci_execute($queryHandle , OCI_NO_AUTO_COMMIT)) {
$error=oci_error($dbHandle);
die($error['message'], $error['code']);
}
$lob->save($mylobvalue); // gives an PHP Warning: OCI-Lob::save(): OCI_INVALID_HANDLE in file.php on line 123
这不会更新吊球并给出:PHP Warning: OCI-Lob::save(): OCI_INVALID_HANDLE in file.php on line 123
答案 0 :(得分:1)
有很多关于如何插入/更新LOB
值的行的示例。
首先,您必须创建一个LOB
描述符:
$desc = oci_new_descriptor($connection, OCI_DTYPE_LOB);
然后使用此描述符作为LOB
占位符的绑定值:
oci_bind_by_name($queryHandle, ":retcol1", $desc, -1, SQLT_CLOB);
然后临时写入数据:
$desc->writeTemporary($data);
然后执行该查询...
可以在documentation +找到更多信息,仔细阅读所有评论以获取更多示例!
一些示例使用$desc->write($data);
+ execute + commit,一些使用execute + $desc->saveFile($data);
+ commit,所有都应该有效。
答案 1 :(得分:0)
正如PLB所说:由于主键值错误,更新查询未更新任何行。这导致了php警告信息。
http://www.oracle.com/technetwork/articles/fuecks-lobs-095315.html