|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43618 missing leading zero in float value
Submitted: 2007-12-17 15:09 UTC Modified: 2007-12-17 23:28 UTC
Avg. Score:3.9 ± 0.8
Reproduced:7 of 7 (100.0%)
Same Version:2 (28.6%)
Same OS:1 (14.3%)
From: marcin dot krzyzanowski at gmail dot com Assigned:
Status: Wont fix Package: OCI8 related
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
38 + 44 = ?
Subscribe to this entry?

 [2007-12-17 15:09 UTC] marcin dot krzyzanowski at gmail dot com
There is missing leading zero for float values

Reproduce code:
$connection = oci_connect("fit","wyoming","");
$statement = oci_parse ($connection, "SELECT NUMBER_COLUMN FROM TABLE");
oci_execute ($statement);

while ($row = oci_fetch_array ($statement, OCI_BOTH)) {
    echo $row[0]."</br>";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-17 18:59 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

| This is a consequence of PHP's general preference for strings and the
| default formatting used.  With Oracle, formatting depends on the data
| access tool. For example by default, SQL*Plus also doesn't give
| leading zeros but a COLUMN, SET NUMBER, or SET NUMWIDTH command will
| affect display.  PHP lets you cast, format numbers with sprintf,
| or use TO_CHAR in queries.
| SQL> select col1 from bug43618_tab;
|       COL1
| ----------
|      .1666
| SQL> set numformat 0999.9999
| SQL> select col1 from bug43618_tab;
|       COL1
| ----------
|  0000.1666


Output is:
    Basic query: string(5) ".1666"
    Cast as float: float(0.1666)
    printf as float: 0.166600
    TO_CHAR: string(10) " 0000.1666"


$c = oci_connect("hr", "hrpwd", "ca-tools1/orcl");

$stmtarray = array("drop table bug43618_tab",
    "create table bug43618_tab(col1 number)",
    "insert into bug43618_tab values (0.1666)"

foreach ($stmtarray as $stmt) {
    $s = oci_parse($c, $stmt);

$statement = oci_parse ($c, "select col1 from bug43618_tab");
oci_execute ($statement);
$row = oci_fetch_array ($statement, OCI_NUM);
echo "Basic query: ";
echo "Cast as float: ";
printf("printf as float: %f\n", $row[0]);

$statement = oci_parse ($c,
                 "select to_char(col1, '0999.9999') from bug43618_tab");
oci_execute ($statement);
$row = oci_fetch_array ($statement, OCI_NUM);
echo "TO_CHAR: ";


 [2007-12-17 23:28 UTC] marcin dot krzyzanowski at gmail dot com
well but cast require to have set NLS_NUMERIC_CHARACTERS = '. ' but for my locales: ', ' is adequate and cast to float return "0.0000" instead of any value.


Is it possible to sync PHP with Oracle Locales automatically and get work all that stuff ?
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Nov 28 11:05:53 2022 UTC