Home > Backend Development > PHP Tutorial > 在php+oracle中clob字段插入大于4000字节报string literal too long

在php+oracle中clob字段插入大于4000字节报string literal too long

WBOY
Release: 2016-06-06 20:51:52
Original
1456 people have browsed it

RT,google说是sql语句太长,可以用绑定变量的形式。项目用的是yii,so,我用yii的bindParam ,倒是解决了 报字符太长的错,可是新的错误来了:仅能绑定要插入 LONG 列的 LONG 值。。
纠结中,,求助。。

这个问题已被关闭,原因:

回复内容:

RT,google说是sql语句太长,可以用绑定变量的形式。项目用的是yii,so,我用yii的bindParam ,倒是解决了 报字符太长的错,可是新的错误来了:仅能绑定要插入 LONG 列的 LONG 值。。
纠结中,,求助。。

挖坟。。隔了这么久,偶然找到了解决方法。。原来Oracle 官方文档就有方法。。汗。。。
使用 php_oci8扩展。
在插入时:

$sql = "INSERT INTO mylobs
          (id,mylob)
        VALUES
          (mylobs_id_seq.NEXTVAL,EMPTY_CLOB())
       RETURNING
          mylob INTO :mylob_loc";

$stmt = oci_parse($conn, $sql);
$myLOB = oci_new_descriptor($conn, OCI_D_LOB);
oci_bind_by_name($stmt, ":mylob_loc", $myLOB, -1, OCI_B_CLOB);
oci_execute($stmt, OCI_DEFAULT) or die ("Unable to execute query\n");
$myLOB->save('mylob_loc');
oci_commit($conn);
oci_free_statement($stmt);
$myLOB->free();
oci_close($conn);
Copy after login

http://www.oracle.com/technetwork/art...

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template