请问php怎么写一个长字符串到oracle9i的xmltype字段?

tssungeng 2004-11-26 02:40:12
直接insert的话,内容长了就提示错误。

请问怎么写一个长字符串到oracle9i的xmltype字段?
...全文
51 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
tssungeng 2004-11-29
自己写了一段代码,但是还不是不行

下面是我的代码:
***************************8

<?
/*
//(tabel_name:articles)DDL; //just for test;
//create table articles (id number(11),content sys.xmltype);
*/
//----------This is insert test----------------------------------
$conn = @OCILogon("in_user","user_in","bigfish");
//$stmt = @OCIParse($conn,"insert into articles (id,content) values(1,sys.xmlType.createXML(EMPTY_CLOB())) RETURNING content INTO:CONTENT");
$stmt = @OCIParse($conn,"insert into articles (id,content) values(1,empty_clob()) RETURNING content INTO:CONTENT");
$clob = @OCINewDescriptor($conn,OCI_D_LOB);
OCIBindByName($stmt,':CONTENT',&$clob,"1",OCI_B_CLOB);
OCIExecute($stmt,OCI_DEFAULT);
if ($clob->save("<root><a>JUST TEST</a></root>"))
{
OCICommit($conn);
echo "Insert succes!";
}
else
{
echo "Insert default!";
}
//---------------Insert end-----------------------------------------
//---------------Select start---------------------------------------
$sql = "select content from articles order by id desc";
$stmt = @OCIParse($conn,$sql);
@OCIExecute($stmt,OCI_DEFAULT);
@OCIFetchInto($stmt,&$rows,OCI_RETURN_LOBS);
echo "<br>Content is:\"".$rows[0]."\"";
//---------------Select end-----------------------------------------
?>

****************************8
报错:

Warning: ociexecute(): OCIStmtExecute: ORA-00932: inconsistent datatypes: expected NUMBER got CLOB in /home/www/bigfish/sgtest/testclob.php on line 12

Warning: save(): OCILobWrite: OCI_INVALID_HANDLE in /home/www/bigfish/sgtest/testclob.php on line 13
Insert default!
Content is:""
Warning: Unknown(): _oci_close_session: OCISessionEnd: ORA-00600: internal error code, arguments: [729], [28], [space leak], [], [], [], [], [] in Unknown on line 0
回复
tssungeng 2004-11-26
谢谢!一起鼎
回复
qcbao 2004-11-26
不知道,帮你顶
回复
相关推荐
发帖
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
帖子事件
创建了帖子
2004-11-26 02:40
社区公告
暂无公告