#40787 [NEW]: Error trying to insert into a CLOB column when using multi-byte charset.
| From: | jarismar at adplabs dot com dot br | Date: | Mon, 12 Mar 2007 17:36:53 +0000 |
| Subject: | #40787 [NEW]: Error trying to insert into a CLOB column when using multi-byte charset. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-110250@lists.php.net to get a copy of this message | ||
From: jarismar at adplabs dot com dot br
Operating system:
PHP version: 5.2.1
PHP Bug Type: PDO related
Bug description: Error trying to insert into a CLOB column when using multi-byte charset.
Description:
------------
I'm using pdo_oci and oracle 10g (10.2).
Trying to insert into a CLOB column using multi-byte charset (AL32UTF8)
results on the following error:
ORA-01461: can bind a LONG value only for insert into a LONG column.
The column datatype in not LONG it's a CLOB !
Changing the connection charset to use WE8ISO8859P1 or any other single
byte charset solve the problem (the insert command ends with no error),
but I loose all non ISO characters (my data gets corrupted).
Reproduce code:
---------------
try {
$sDSN = "oci:dbname=$sConId;charset=AL32UTF8";
$oPDO = new PDO($sDSN, $sUserName, $sPassword);
$oPDO->beginTransaction();
$oStmt = $oPDO->prepare("insert into test_clob (id, data) values (:id,
EMPTY_CLOB())");
$iID = 1;
$oStmt->bindParam(':id', $iID);
if ($oStmt->execute()) {
$oStmt = $oPDO->prepare("update test_clob set data=:value where
id=1");
$sData = str_repeat('x', 65535);
$oStmt->bindParam(':value', $sData);
if ($oStmt->execute() === false) {
throw new Exception('Error on update clob');
}
} else {
throw new Exception('Error on insert EMPTY_CLOB');
}
$oStmt = $oPDO->prepare("select data from test_clob where id = :id");
$oStmt->bindParam('id', $iID);
$oStmt->execute();
$oResult = $oStmt->fetch();
echo 'Read '.strlen(stream_get_contents($oResult['DATA'])).' characters
<br>';
$oPDO->commit();
} catch (Exception $oE) {
if ($oStmt) {
echo '<pre>';print_r($oStmt->errorInfo());echo
"</pre><br>\n";
}
echo $oE->getMessage()."<br>\n";
}
$oPDO = null;
Expected result:
----------------
Read 65535 characters
Actual result:
--------------
Array
(
[0] => HY000
[1] => 1461
[2] => OCIStmtExecute: ORA-01461: can bind a LONG value only for
insert into a LONG column
(ext\pdo_oci\oci_statement.c:142)
)
Error on update clob
--
Edit bug report at http://bugs.php.net/?id=40787&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40787&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40787&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40787&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40787&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40787&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40787&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40787&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40787&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40787&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40787&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40787&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40787&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40787&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40787&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40787&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40787&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40787&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40787&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40787&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40787&r=mysqlcfg