我遇到一个关于php往oracle里存取clob的问题
$clob = oci_new_descriptor($oci_handler,OCI_D_LOB);
$stmt = oci_parse($oci_handler,"INSERT INTO t_politics_test (id,content) values (1,EMPTY_LOB()) returning content into :content");
oci_define_by_name($stmt,':content',$clob,SQLT_CLOB);
oci_bind_by_name($stmt,':content',$clob,-1,SQLT_CLOB);
$content = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
oci_execute($stmt,OCI_DEFAULT);
if($clob->savefile($content)){
oci_commit($oci_handler);
}
else{
echo 'fail';
}
oci_free_descriptor($clob);
oci_free_statement($stmt);
oci_close($oci_handler);
oci_execute一直返回false,oci_error也返回false
请问如何解决
$clob = oci_new_descriptor($oci_handler,OCI_D_LOB);
$stmt = oci_parse($oci_handler,"INSERT INTO t_politics_test (id,content) values (1,EMPTY_LOB()) returning content into :content");
oci_define_by_name($stmt,':content',$clob,SQLT_CLOB);
oci_bind_by_name($stmt,':content',$clob,-1,SQLT_CLOB);
$content = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
oci_execute($stmt,OCI_DEFAULT);
if($clob->savefile($content)){
oci_commit($oci_handler);
}
else{
echo 'fail';
}
oci_free_descriptor($clob);
oci_free_statement($stmt);
oci_close($oci_handler);
oci_execute一直返回false,oci_error也返回false
请问如何解决
VALUES('".$TITLE."',empty_clob(),".$ID.",".$REVIEW.",to_date('".$ADDDATE."','yyyy-mm-dd'),'".$_COOKIE["USERNAME"]."',to_date('".$EDITDATE."','yyyy-mm-dd'),'".$START_END_TIME."','".$VENUE."','".$IMAGE."','".$ORGANIZERS."','".$SPONSOR."','".$MEDIA."',".$HIT.") returning CONTENT into :CONTENT";
//echo $sql;exit();
$stmt = OCIParse($ociconn, $sql);
$clob = OCINewDescriptor($ociconn, OCI_D_LOB);
OCIBindByName ($stmt, ":CONTENT", &$clob, -1, OCI_B_CLOB);
if(!OCIExecute($stmt,OCI_DEFAULT)) print_r(OCIError($stmt));
if($clob->save($CONTENT)){
OCICommit($ociconn);
$clob->free();
OCIFreeStatement($stmt);
echo '<script language="javascript">alert("数据添加成功");location.href="你的页"</script>';
exit();
}else{
print_r(OCIError($stmt));
$clob->free();
OCIFreeStatement($stmt);
}
思路应该没有问题吧???
下面是实现:
char* strStmt1 = "insert into oci values(:name , :sex , empty_blob()) returning pos into :lob"; //插入一个空的BLOB数据 pos为字段名称
Prepare(strStmt1);
BindLob(SQLT_BLOB,3);
Execute(1);
//用'FOR UPDATE'语句,获取到lob定位符,CStatement类的成员(m_pLobLocator),然后写操作。
char* strStmt2 = "select pos from oci where name = :c for update";
Prepare(strStmt2);
char* buf = "f";//一个字段值
Bind(SQLT_STR,":c",buf,sizeof(buf),0);
int lob = DefineLob(SQLT_BLOB,1);
//写入LOB数据
char* str = "catmdgb";//数据内容(任意的)。
WriteLob(lob,(dvoid*)str,strlen(str)+1);
请问是什么地方有问题?