Details
Description
When I insert decimals into database I get the following error message:
ORA-01722: invalid number
Oracle wants decimals (e.g. NUMBER(5,2)) separated by comma instead of a dot. I think the reason is that I use the german version of Windows. I tried to modify the following method of \Doctrine\DBAL\Driver\OCI8\OCI8Statement::bindValue() just for testing of course:
public function bindValue($param, $value, $type = null)
{
if (is_float($value)) {
$value = str_replace('.', ',', (string) $value); // <--
}
return $this->bindParam($param, $value, $type);
}
With this modification I do not get the error anymore.
It would be great if a solution could be found. The strange thing is, if I query "SELECT * from nls_database_parameters where PARAMETER='NLS_NUMERIC_CHARACTERS'" I get ".," which means that a dot is already used as decimal separator. Maybe Oracle preferes the Locale of the OS?!
Maybe you could provide a setting which defines what separator should be used for decimals.
I found some Links that might be interesting regarding this issue:
- http://docs.oracle.com/cd/E19455-01/806-0169/overview-9/index.html (Oracle Docs - Decimal and Thousands Separators)
- https://forums.oracle.com/forums/thread.jspa?threadID=35398
- http://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_options072.htm
- https://forums.oracle.com/forums/thread.jspa?threadID=899739
- http://symfony-blog.driebit.nl/2010/09/doctrine-and-oracle-under-windows/
Activity
| Field | Original Value | New Value |
|---|---|---|
| Project | Doctrine 2 - ORM [ 10032 ] | Doctrine DBAL [ 10040 ] |
| Key | DDC-2013 |
|
| Affects Version/s | 2.2.2 [ 10197 ] | |
| Affects Version/s | 2.2.2 [ 10195 ] | |
| Component/s | ORM [ 10012 ] | |
| Component/s | Mapping Drivers [ 10044 ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.3 [ 10184 ] | |
| Resolution | Fixed [ 1 ] |
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-345, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
I found out that the database session has the parameter 'NLS_NUMERIC_CHARACTERS', too.
When I query it by the following SQL query:
I get this result:
With doctrine I can get the parameter with this (in Symfony2):
In this case I get this output:
And with
I can change the parameter.
When I execute the above query before I do my insert with decimal values, everything works as expected
But it would be nicer if I could do that with a configuration.