ID:          40787
 Comment by:  inbox at trevorbramble dot com
 Reported By: jarismar at adplabs dot com dot br
 Status:      Assigned
 Bug Type:    PDO related
 PHP Version: 5.2.1
 Assigned To: wez
 New Comment:

I am experiencing the same error as charles at crh-systems dot com,
however I'm trying to enter a string into a varchar2(4000) column.

I've gone through a lot in the course of diagnosing this problem so I
can't recall exactly what changed, but originally I was getting this
error:

ORA-01460: unimplemented or unreasonable conversion requested

The resolution has been to define the length for that parameter:

$stmt->bindParam( ':notes', $this->notes, PDO::PARAM_STR, 4000 );

Why this fixes the problem is still a mystery.  None of the inserted
data is lost, so there don't appear to have really been too many bytes
in the string to insert.  I'm not experiencing the same problem with any
of the smaller columns (a string of 4 or more characters will insert
into a column defined varchar2(10), for example).


Previous Comments:
------------------------------------------------------------------------

[2008-04-01 03:28:49] charles at crh-systems dot com

I am having the same problem, 
OCIStmtExecute: ORA-01461: can bind a LONG value only for insert into a
LONG column

I can only get 1333 chars to insert into a clob field no matter which
connection charset I use.
4000 / 3 = 1333.333

...any fixes?

------------------------------------------------------------------------

[2007-03-12 18:27:14] jarismar at adplabs dot com dot br

Many thanks for the faster reply, I've tested with suggested snapshot
PHP Version: 5.2.2-dev
Build Date : Mar 12 2007 16:05:36

But the problem still occurs.

It seems that PDO get wrong data type for the CLOB column.
I can just insert up to 4000 bytes into the CLOB column, because the
extension thinks its handling a LONG column.

------------------------------------------------------------------------

[2007-03-12 18:03:41] tony2...@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip



------------------------------------------------------------------------

[2007-03-12 17:36:53] jarismar at adplabs dot com dot br

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 this bug report at http://bugs.php.net/?id=40787&edit=1

Reply via email to