dbTalk Databases Forums  

OCI8: Numbers fetched as strings

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss OCI8: Numbers fetched as strings in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default OCI8: Numbers fetched as strings - 09-11-2008 , 11:58 AM






I'm playing with PHP and its oci8 extension and I'm facing a curious
issue: numeric fields are returned as strings and, to make it worse,
they're formatted using locale settings (well, sort of). For instance:

1234.56 ---> "1234,56"

According to the documentation I've read, it isn't a bug: it's
intentional. The "Underground PHP and Oracle Manual" describes the
problem but it doesn't suggest any solution.

Am I supposed to write a custom parser to convert numeric strings into
floats and pray that the DBA will never change the locale settings? Is
it enough to run...

alter session set nls_territory=america nls_language=american

.... when I open the (persistent) connection? (I still get strings but at
least they're easy to cast.)


--
-- 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
--

Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: OCI8: Numbers fetched as strings - 09-12-2008 , 02:13 AM






"Álvaro G. Vicario" <alvaroNOSPAMTHANKS (AT) demogracia (DOT) com> wrote:
Quote:
I'm playing with PHP and its oci8 extension and I'm facing a curious
issue: numeric fields are returned as strings and, to make it worse,
they're formatted using locale settings (well, sort of). For instance:

1234.56 ---> "1234,56"

According to the documentation I've read, it isn't a bug: it's
intentional. The "Underground PHP and Oracle Manual" describes the
problem but it doesn't suggest any solution.

Am I supposed to write a custom parser to convert numeric strings into
floats and pray that the DBA will never change the locale settings? Is
it enough to run...

alter session set nls_territory=america nls_language=american

... when I open the (persistent) connection? (I still get strings but at
least they're easy to cast.)
I would change the session parameter NLS_NUMERIC_CHARACTERS which controls
the decimal comma character.

Yours,
Laurenz Albe


Reply With Quote
  #3  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: OCI8: Numbers fetched as strings - 09-12-2008 , 02:13 AM



"Álvaro G. Vicario" <alvaroNOSPAMTHANKS (AT) demogracia (DOT) com> wrote:
Quote:
I'm playing with PHP and its oci8 extension and I'm facing a curious
issue: numeric fields are returned as strings and, to make it worse,
they're formatted using locale settings (well, sort of). For instance:

1234.56 ---> "1234,56"

According to the documentation I've read, it isn't a bug: it's
intentional. The "Underground PHP and Oracle Manual" describes the
problem but it doesn't suggest any solution.

Am I supposed to write a custom parser to convert numeric strings into
floats and pray that the DBA will never change the locale settings? Is
it enough to run...

alter session set nls_territory=america nls_language=american

... when I open the (persistent) connection? (I still get strings but at
least they're easy to cast.)
I would change the session parameter NLS_NUMERIC_CHARACTERS which controls
the decimal comma character.

Yours,
Laurenz Albe


Reply With Quote
  #4  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: OCI8: Numbers fetched as strings - 09-12-2008 , 02:13 AM



"Álvaro G. Vicario" <alvaroNOSPAMTHANKS (AT) demogracia (DOT) com> wrote:
Quote:
I'm playing with PHP and its oci8 extension and I'm facing a curious
issue: numeric fields are returned as strings and, to make it worse,
they're formatted using locale settings (well, sort of). For instance:

1234.56 ---> "1234,56"

According to the documentation I've read, it isn't a bug: it's
intentional. The "Underground PHP and Oracle Manual" describes the
problem but it doesn't suggest any solution.

Am I supposed to write a custom parser to convert numeric strings into
floats and pray that the DBA will never change the locale settings? Is
it enough to run...

alter session set nls_territory=america nls_language=american

... when I open the (persistent) connection? (I still get strings but at
least they're easy to cast.)
I would change the session parameter NLS_NUMERIC_CHARACTERS which controls
the decimal comma character.

Yours,
Laurenz Albe


Reply With Quote
  #5  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: OCI8: Numbers fetched as strings - 09-12-2008 , 02:13 AM



"Álvaro G. Vicario" <alvaroNOSPAMTHANKS (AT) demogracia (DOT) com> wrote:
Quote:
I'm playing with PHP and its oci8 extension and I'm facing a curious
issue: numeric fields are returned as strings and, to make it worse,
they're formatted using locale settings (well, sort of). For instance:

1234.56 ---> "1234,56"

According to the documentation I've read, it isn't a bug: it's
intentional. The "Underground PHP and Oracle Manual" describes the
problem but it doesn't suggest any solution.

Am I supposed to write a custom parser to convert numeric strings into
floats and pray that the DBA will never change the locale settings? Is
it enough to run...

alter session set nls_territory=america nls_language=american

... when I open the (persistent) connection? (I still get strings but at
least they're easy to cast.)
I would change the session parameter NLS_NUMERIC_CHARACTERS which controls
the decimal comma character.

Yours,
Laurenz Albe


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.