|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37059 can not insert a long raw column
Submitted: 2006-04-12 16:00 UTC Modified: 2006-04-13 12:57 UTC
From: a dot vigetti at provincia dot grosseto dot it Assigned:
Status: Closed Package: OCI8 related
PHP Version: 5.1.2 OS: debian linux 2.6.12-1-686-smp
Private report: No CVE-ID:
 [2006-04-12 16:00 UTC] a dot vigetti at provincia dot grosseto dot it
Oracle library version 10G R2.
I need to insert into an oracle table with a long raw,
i can't change the column type because another application use the same table and i can change the application.
I experinced the same problem with other version of php/oci libs/Oracle database.

Reproduce code:
This is a small code example that fails:

create table longRawTable( id number(10), fileimage long raw);
$db=ocilogon("user","password", "database");
$qs = "insert into longRawTable  (id, fileimage)" .
  " values (:id, :fileimage)";
$stmt = OCIParse($db, $qs);
$fileimage = file_get_contents( "a_file" );
OCIBindByName ( $stmt, ":id", $i, -1);
OCIBindByName ( $stmt, ":fileimage", $fileimage, -1);
ociexecute($stmt, $OCI_DEFAULT);

When i try this script i obtain the following error:
Warning: ociexecute(): ORA-01461: can bind a LONG value only for insert into a LONG column in ..../LongRow.php on line 13

Using a column of type LONG and storing data with the bin2hex function all is OK.
Its a php or OCI problem?
I try a similar script in perl using DBD::Oracle on the same machine linked with the same OCI libs without problems.

Aldo Vigetti 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-12 19:25 UTC]
Fixed in 5.1 and HEAD.

You should use:
OCIBindByName ( $stmt, ":fileimage", $fileimage, -1, SQL_LBI);

And also note this:
ociexecute($stmt, $OCI_DEFAULT); <-- OCI_DEFAULT is not a variable, it's a constant.
 [2006-04-13 12:01 UTC] a dot vigetti at provincia dot grosseto dot it
Ok i fixed  OCI_DEFAULT and tried:
OCIBindByName ( $stmt, ":fileimage", $fileimage, -1, SQL_LBI);

but the result is now:

Warning: ocibindbyname() expects parameter 5 to be long, string given in /root/lavori/ArchiproNew/prove/LongRow.php on line 12

Warning: ociexecute(): ORA-01008: not all variables bound in /root/lavori/ArchiproNew/prove/LongRow.php on line 13

I tried also SQLT_LBI in OciBindByName and got the same error message.
Another little but important mistake in my first post:
i cannot change the other application that use the same table.
 [2006-04-13 12:04 UTC]
This constant is available only in CVS version.
 [2006-04-13 12:52 UTC] a dot vigetti at provincia dot grosseto dot it
OK i tried the CVS snapshot php5.1-200604130230.tar.bz2 and everything works fine.
This patch will be standard in 5.1.3?

thanks Tony.

 [2006-04-13 12:57 UTC]
Sure, it will appear in the upcoming 5.1.3 release, as well as in PHP6.
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC