<?php
// by [email protected]// Use option: OCI_DEFAULT for execute command to delay execution
OCIExecute($stmt, OCI_DEFAULT);// for retrieve data use (after fetch):$result = OCIResult($stmt, $n);
if (is_object ($result)) $result = $result->load();// For INSERT or UPDATE statement use:$sql = "insert into table (field1, field2) values (field1 = 'value',
 field2 = empty_clob()) returning field2 into :field2";
OCIParse($conn, $sql);
$clob = OCINewDescriptor($conn, OCI_D_LOB);
OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
$clob->save ("some text");
OCICommit($conn);?>
参考上面的代码吧

解决方案 »

  1.   

    在Oracle 7.3下没有CLOB类型,我使用的LONG类型,是不是就不能使用
    OCINewDescriptor($conn, OCI_D_LOB);了。我使用后代码就出现下面的错误Warning: OCIStmtExecute: ORA-01024: invalid datatype in OCI call in D:\wwwroot\savedoc.php on line 14 // For INSERT or UPDATE statement use:
    $sql = "insert into TB_WEB_UNITDOC (N_DOCID, N_UNITID,C_DOCMENT) 
      values (SEQ_WEB_UNITDOC.NEXTVAL,$dw,C_DOCMENT = empty_clob()) returning C_DOCMENT into :field2";
    $stmt = OCIParse($conn, $sql);
    $clob = OCINewDescriptor($conn, OCI_D_LOB);
    OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB);
    OCIExecute($stmt, OCI_DEFAULT);
    $clob->save ("TEST TEST TEST");
    OCICommit($conn);
      

  2.   

    我也顺便请教一下,我用的是ORACLE8,我如何把一个文件(文本或图片什么的)存入数据库?字段应该是那一类型?
      

  3.   

    如果是ASCII文本可使用:CLOB如果是二进制文档可使用:BLOB