如何在PHP中处理Oracle CLOB?

I asked a question like this yesterday, but I haven't got any answers yet.

The point: How can I get the CLOB reference such as in an insert into or update statement:

$sql = "INSERT INTO table (data) VALUES (EMPTY_CLOB()) RETURNING data INTO :data";
$statement = oci_parse($conn, $sql);
$descriptor = oci_new_descriptor($conn, OCI_DTYPE_LOB);
oci_bind_by_name($statement, ':data', $descriptor, -1, OCI_B_CLOB);
oci_execute($statement);
$descriptor->save('5000 chars');
oci_free_descriptor($descriptor);

So, I want call the clob save method without insert and update statement. So I tried:

$sql = "SELECT data FROM table WHERE id = " . $fooid;
$statement = oci_parse($conn, $sql);
oci_execute($statement);
$row = oci_fetch_assoc($statement);
$row['DATA']->save('5000 chars');

How to?

Thx.

1个回答

$sql = "INSERT INTO table t (t.data) VALUES (EMPTY_CLOB()) RETURNING t.data.clob INTO :data";
$statement = oci_parse($conn, $sql);
$descriptor = oci_new_descriptor($conn, OCI_DTYPE_LOB);
oci_bind_by_name($statement, ':data', $descriptor, -1, OCI_B_CLOB);
oci_execute($statement, 0); //no commit!!!
$descriptor->save('5000 chars');
oci_commit($conn);
oci_free_descriptor($descriptor);
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐