问题代码如下:         $itemlist='abcdefg.....';//长字符串
$sql='BEGIN NCCM_INTERFACE_HISDETAIL(:orgcode,:inhiscode,:inputer,:items); END;';
$conn=oci_connect('chis','chis123','WSS','UTF8');
$clob = oci_new_descriptor($conn, OCI_D_LOB);
$stmt = oci_parse($conn, $sql);
oci_bind_by_name($stmt, ":orgcode", $orgcode, -1);
oci_bind_by_name($stmt, ":inhiscode", $inhiscode, -1);
oci_bind_by_name($stmt, ":inputer", $inputer, -1);
oci_bind_by_name($stmt, ":items", $clob, -1, SQLT_CLOB);
$clob->write($itemlist);
oci_execute($stmt);
存储过程中的一个参数是CLOB类型(大文本对象),PHP中的超长字符串在传参的时候,一直提示
Warning: OCI-Lob::write() [oci-lob.write]: OCI_INVALID_HANDLE in E:\php\htdocs\PHPRPC\func.php on line 315Oracle存储过程我在PL/SQL中测试没问题。

解决方案 »

  1.   

    切记:对数据库大对象,使用了类似c语言指针的访问机制。so存储过程中不能“提交”数据库的操作,一旦“提交”,对象关闭,之前返回给程序的指针也不能再指向正确的地址。OCI_INVALID_HANDLE,正是在告诉你这个事实。解决:请修正你的存储过程。
      

  2.   

    问题在stackoverflow上得到解决,原文如下:
    The issue is you are binding a collection object while Oracle expects the bound type to be SQLT_CHR, e.g. a VARCHAR. Thus, Oracle will try to use the bound object in a string context, which is not possible because the collection apparently has no __toString method implemented. Hence you get the error that the object could not be converted to string.I am not sure on this, but try to supply a different type in the binding call, for instance:oci_bind_by_name($stmt, ":items", $collection,-1, OCI_B_NTY);