Bug #69590 [Opn->Nab]: OCI extension: oci_field_scale returns 0 for float expression
Edit report at https://bugs.php.net/bug.php?id=69590&edit=1
ID: 69590
Updated by: sixd@php.net
Reported by: vavra at 602 dot cz
Summary: OCI extension: oci_field_scale returns 0 for float
expression
-Status: Open
+Status: Not a bug
Type: Bug
-Package: *General Issues
+Package: OCI8 related
Operating System: Windows7 32bit
PHP Version: 5.6.8
-Assigned To:
+Assigned To: sixd
Block user comment: N
Private report: N
New Comment:
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 isn't specific to PHP. Try 'CREATE TABLE testtab as select a, b, a/b division,
21/2 constant_division from test_division' and change your PHP code to query testtab. You will
see the same result.
- The columns are of type NUMBER. Check oci_field_precision(). It is zero in all cases. From Table
6-8 in the OCI manual https://docs.oracle.com/database/121/LNOCI/oci06des.htm#LNOCI16458
it says "When precision is 0, NUMBER(precision, scale) can be represented simply as
NUMBER."
- It seems a semi-interesting quirk that the runtime/compile time evaluation is returning different
scales.
Previous Comments:
------------------------------------------------------------------------
[2015-05-07 06:55:02] vavra at 602 dot cz
Description:
------------
Lets consider this table
create table test_division(a number, b number);
with values
insert into test_division values (21, 2);
and this query
select a, b, a/b division, 21/2 constant_division from test_division
leads to result in our system
{
'A' =>
double(21)
'B' =>
double(2)
'DIVISION' =>
int(10)
'CONSTANT_DIVISION' =>
double(10.5)
}
The problem is that oci_field_scale(., 'DIVISION') returns 0. (Note: for
'CONSTANT_DIVISION' returns -127). In our system we decide according to the
oci_field_scale result, if to call intval or floatval on column value. OCI driver returns always
string values and we need to convert them.
Oracle version is Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production,
Windows.
Expected result:
----------------
oci_field_scale(., 'DIVISION') should return 1, or -127 (as says documentation: For FLOAT
columns, precision is nonzero and scale is -127.)
Actual result:
--------------
0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69590&edit=1
Thread (4 messages)