0

我昨天问了这样一个问题,但我还没有得到任何答案。

要点:如何在 insert into 或 update 语句中获取 CLOB 引用:

$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);

所以,我想在没有插入和更新语句的情况下调用 clob 保存方法。所以我尝试了:

$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');

如何?

谢谢。

4

1 回答 1

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);
于 2013-04-17T14:55:51.480 回答