php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39271 oci_bind_array_by_name produces incorrect data
Submitted: 2006-10-26 20:46 UTC Modified: 2006-10-27 21:56 UTC
From: quelch at udel dot edu Assigned:
Status: Not a bug Package: OCI8 related
PHP Version: 5.1.6 OS: Redhat EL 3
Private report: No CVE-ID: None
 [2006-10-26 20:46 UTC] quelch at udel dot edu
Description:
------------
Utilizing the oci_bind_array_by_name function in Oracle 10.2.0.1 results in incorrect data being returned for NUMBER array data.

This error also occurs with the php5.2-200610261830 snapshot.

Configure line: ./configure -with-oci8 --with-gd --enable-gd-imgstrttf --enable-gd-native-ttf  --with-ttf --with-freetype-dir --with-apxs=/www/bin/apxs --with-png --with-zlib --with-jpeg --enable-xmlwriter --without-pear

My database is set up with native code compile option for PL/SQL in case that makes a difference.

Reproduce code:
---------------
The code used can be found here: http://www-dev.quelch.org/ws/test.html

Expected result:
----------------
Array
(
    [0] => 4
    [1] => 3
    [2] => 2
    [3] => 1
    [4] => 0
)

Actual result:
--------------
Array
(
    [0] => 1473
    [1] => 1217
    [2] => 961
    [3] => 705
    [4] => 128
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-26 20:50 UTC] tony2001@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


 [2006-10-26 21:40 UTC] quelch at udel dot edu
I get the same error with the php5.2-200610262030 snapshot as I did with the php5.2-200610261830 snapshot and 5.1.6.
Thanks.
 [2006-10-27 08:37 UTC] tony2001@php.net
Change SQLT_NUM to SQLT_INT and it works fine.
There is no difference for OCI8 between those two bind types (they are handled by the same function in the very same way), so there must be some difference in OCI library itself.
 [2006-10-27 14:56 UTC] quelch at udel dot edu
Thanks. Is the documentation going to be updated to reflect this workaround?
 [2006-10-27 21:25 UTC] quelch at udel dot edu
However, if you have a column defined, say, as number (4,2) and place decimal values in it, you can't then get this data out using the "SQLT_INT" constant, as it truncates. I've updated my test case to do that at the link below.

In this case, using SQLT_NUM gives me:

Array
(
    [0] => 2688449
    [1] => 2032833
    [2] => 1377217
    [3] => 721601
    [4] => 128
)

Where I should get
Array
(
    [0] => 4.4
    [1] => 3.3
    [2] => 2.2
    [3] => 1.1
    [4] => 0
)

Using the SQLT_INT constant gets me:
Array
(
    [0] => 4
    [1] => 3
    [2] => 2
    [3] => 1
    [4] => 0
)
Which is not right either.
 [2006-10-27 21:29 UTC] quelch at udel dot edu
The last comment also applies if you leave the original field definition as "NUMBER". Thus is seems that with the current code, one can't retrieve floating point data from the database using oci_bind_array_by_name.
Is that a correct deduction?
Thanks.
 [2006-10-27 21:56 UTC] tony2001@php.net
This one is pretty plain too - NUMBER(x,y) is just an alias for FLOAT, so you should be usign SQLT_FLT.
Why Oracle doesn't return an error when you specify wrong bind type, I do not know.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC