如何在oracle中用PHP更新LOB? (OCI_INVALID_HANDLE) [英] how to update a LOB with PHP in oracle? (OCI_INVALID_HANDLE)

查看:152
本文介绍了如何在oracle中用PHP更新LOB? (OCI_INVALID_HANDLE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以插入的相同方式来更新(C)LOB. (插入已在工作).

i'm trying to do an update a (C)LOB in the same way i do an insert. (insert is already working).

$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

这不会更新lob,并给出:PHP Warning: OCI-Lob::save(): OCI_INVALID_HANDLE in file.php on line 123

this does not update the lob and gives an: PHP Warning: OCI-Lob::save(): OCI_INVALID_HANDLE in file.php on line 123

推荐答案

关于如何使用LOB值插入/更新行的例子很多.

There are dozens of examples of how to insert/update a row with a LOB value.

首先,您必须创建一个LOB描述符:

First of all, you have to create a LOB descriptor:

$desc = oci_new_descriptor($connection, OCI_DTYPE_LOB);

然后使用此描述符作为LOB占位符的绑定值:

Then use this descriptor as your binding value for the LOB placeholder:

oci_bind_by_name($queryHandle, ":retcol1", $desc, -1, SQLT_CLOB);

然后临时写入数据:

$desc->writeTemporary($data);

然后执行该查询...

And after that execute that query...

有关更多信息,请参见文档 +仔细阅读所有注释以获取更多示例!

More information could be find at the documentation + read carefully all the comments for more examples!

一些示例使用$desc->write($data); + execute + commit,一些示例使用execute + $desc->saveFile($data); + commit,所有示例均应正常工作.

Some examples use $desc->write($data); + execute + commit, some use execute + $desc->saveFile($data); + commit, all should work.

这篇关于如何在oracle中用PHP更新LOB? (OCI_INVALID_HANDLE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆