Oracle OCI8 returns everything as string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

    Oracle OCI8 returns everything as string

    I've been evaluating the possibility of modifying an existing web app
    with Oracle backend to use the OCI8 functions rather than ODBC. I was
    attracted by some specific functionalities (specifying the DB charset on
    connect, LOB handling...) and I also wanted to test whether there was
    any performance improvement.

    I've soon noticed that the OCI API returns numeric values as
    locale-formatted strings; e.g., 3.14 becomes "3,14". According to docs
    it's intentional.

    My app depends on receiving decimal numbers as PHP floats because it has
    to do maths with them and even when writing to page they need to be
    properly formatted (I want "1.234,57", not "1234,567") . It seems that I
    need to build my own abstraction layer and:

    1. On every session, change the decimal separator to dot.
    2. On every query, find out which fields are numeric.
    3. On every row, cast numeric values to float.

    This approach seems worse that using good old ODBC. My question is: Is
    it possible to override this OCI "feature" and just get numbers as numbers?


    --
    -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    -- Mi sitio sobre programación web: http://bits.demogracia.com
    -- Mi web de humor al baño María: http://www.demogracia.com
    --
Working...