Cannot insert CLOB into table with PDO_OCI
I'm trying to insert data into a CLOB field with PDO, but I always get
an error (working with a BLOB instead of a CLOB works, though):
OCIStmtExecute: ORA-00932: Inkonsistente Datentypen: BLOB erwartet, CLOB
erhalten (ext\pdo_oci\oci_statement.c:142)
That would be in english:
OCIStmtExecute: ORA-00932: inconsistent datatypes: expected BLOB got
CLOB (ext\pdo_oci\oci_statement.c:142)
I'm using PHP 5.1.4 and a full Oracle 10g client under Windows XP.
Does anyone know what I'm doing wrong?
Thanks in advance for your help!
Reproduce code:
---------------
php:
/* TABLE STRUCTURE:
================
TEXT CLOB
DIGIT NUMBER(10) */
try { $db = new PDO('oci:dbname=oracle_test;charset=UTF-8', 'scott',
'tiger'); }
catch (PDOException $e) { echo 'Failed to obtain database handle ' .
$e->getMessage(); exit; }
$stmt = $db->prepare("insert into UTF8TEST (text, digit) " .
"VALUES ( null, ?) ".
"RETURNING text INTO ?");
$fp = fopen('utf8text.txt', 'rb');
$digit = '12345';
$stmt->bindParam(1, $digit);
$stmt->bindParam(2, $fp, PDO::PARAM_LOB);
$db->beginTransaction();
if ( $stmt->execute() ) { echo "Successfully inserted UTF-8 into
table\n"; } else { print_r($stmt->errorInfo()); }
$db->commit();