如何一次插入多个clob对象到Oracle?

oop2000 2007-10-03 11:45:15
环境:
windows 2003 sp2 ent
Oracle9.2.0.8 for win
php 5.2.3

问题:
如何一次插入多个clob到Oracle呢?

在网上找了半天,没有发现有这样的介绍的.我测试了Oracle的例子:
http://www.oracle.com/technology/pub...ecks_lobs.html

Inserting a LOB

To INSERT an internal LOB, you first need to initialize the LOB using the respective Oracle EMPTY_BLOB or EMPTY_CLOB functions—you cannot update a LOB that contains a NULL value.

Once initialized, you then bind the column to a PHP OCI-Lob object and update the LOB content via the object's save() method.

The following script provides an example, returning the LOB type from the INSERT query:

<?php
// connect to DB etc...

$sql = "INSERT INTO
mylobs
(
id,
mylob
)
VALUES
(
mylobs_id_seq.NEXTVAL,
--Initialize as an empty CLOB
EMPTY_CLOB()
)
RETURNING
--Return the LOB locator
mylob INTO :mylob_loc";

$stmt = oci_parse($conn, $sql);

// Creates an "empty" OCI-Lob object to bind to the locator
$myLOB = oci_new_descriptor($conn, OCI_D_LOB);

// Bind the returned Oracle LOB locator to the PHP LOB object
oci_bind_by_name($stmt, ":mylob_loc", $myLOB, -1, OCI_B_CLOB);

// Execute the statement using , OCI_DEFAULT - as a transaction
oci_execute($stmt, OCI_DEFAULT)
or die ("Unable to execute query\n");

// Now save a value to the LOB
if ( !$myLOB->save('INSERT: '.date('H:i:s',time())) ) {

// On error, rollback the transaction
oci_rollback($conn);

} else {

// On success, commit the transaction
oci_commit($conn);

}

// Free resources
oci_free_statement($stmt);
$myLOB->free();


// disconnect from DB etc.
?>

这个例子也仅仅用了一个clob,我想插入多个clob有什么好办法么?
谢谢了...
...全文
178 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
greenweather 2012-02-17
  • 打赏
  • 举报
回复
我今天也在研究多个CLOB写入,发现后面写的会覆盖前面的字段,

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧