php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21915 ociBindByName doesn't work properly with char columns
Submitted: 2003-01-28 02:22 UTC Modified: 2003-01-28 11:54 UTC
From: michael dot virnstein at brodos dot de Assigned:
Status: Not a bug Package: OCI8 related
PHP Version: 4.2.3 OS: Linux
Private report: No CVE-ID: None
 [2003-01-28 02:22 UTC] michael dot virnstein at brodos dot de
when i select from a oracle8i:
----------------------------------
$stmt = ociparse($conn, "Select * from t_table where c_column = 'text'");
ociexecute($stmt);
-------------------------
and c_column is a char column, everything works fine, even if the data i'm asking for is shorter than the column.
(c_column is a char(10) and i'm looking for 'text')
but as soon as i use ocibindbyname, i won't get a result back:
-------------------------
$stmt = ociparse($conn, "Select * from t_table where c_column = :bindvar");
$text = 'text';
ocibindbyname($stmt, ":bindvar", &$text, -1);
ociexecute($stmt);
-------------------------
it also doesn't work, if i set the length-parameter in ocibindbyname to the length of the char column or lenght+1:
-------------------------
$stmt = ociparse($conn, "Select * from t_table where c_column = :bindvar");
$text = 'text';
ocibindbyname($stmt, ":bindvar", &$text, 10);
ociexecute($stmt);
-------------------------
ocibindbyname only works with char columns, when the data of the bindvariable is as long as the char column or if like-operator and % is used:
-------------------------
$stmt = ociparse($conn, "Select * from t_table where c_column like :bindvar");
$text = 'text%';
ocibindbyname($stmt, ":bindvar", &$text, -1);
ociexecute($stmt);
------------------------- 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-28 02:42 UTC] michael dot virnstein at brodos dot de
to make things clearer:
c_column is a char(10) column, but there's also data stored that is shorter, e.g. 'text'. Therefore "Select * from t_table where c_column = 'text'" works.
 [2003-01-28 05:41 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

PHP 4.3.0
 [2003-01-28 11:54 UTC] maxim@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is actually an expected behavior. Variable returned by bind from Oracle needs to fit into the POHP variable, thus you whether declare $text as 'texttextte'; (10 chars) or set it in OCIBindByName (10).

Maxim Maletsky
 [2003-01-28 12:04 UTC] michael dot virnstein at brodos dot de
I just can say that setting the length in ocibindbyname doesn't solve the problem also. And i still am curious about why "Select * from t_table where c_column = 'text'" works. I already said, the column is a char(10) but the data stored in there is e.g. 'text', so 4 chars filled with blanks on database side, so it fits into the char(10) column.
why is it working without bindvars and with it is not and why is this an expected behaviour? Anyway...thanx for your answers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 16:01:36 2024 UTC