[DDC-2731] Error when inserting in oracle DB : ORA-01861: literal does not match format string Created: 09/Oct/13  Updated: 10/Oct/13  Resolved: 10/Oct/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Abdelghafour IFTAH Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Symfony2 - Doctrine2 - Linux



 Description   

I moved my project from MySQL to Oracle, and I get this error when I try to insert into the database.

This error is caused by the date format, in my form the date format is dd/mm/yyyy, so my question is HOW DOES SYMFONY2 GET THE DATE FORMAT BEFORE DB INSERT?

I added this date_default_timezone_set("Europe/Paris"); to my config.php and app_dev.php, but nothing changed.

An exception occurred while executing 'INSERT INTO arborescence (IDNT_ARBR, NOM_ARBR, DATE_CREATION, IDNT_SERV, IDNT_UTLS) VALUES (?, ?, ?, ?, ?)' with params [7, "B", "2013-10-09 00:00:00", 7, 1]:

ORA-01861: literal does not match format string

Any ideas on how to solve this would be really appreciated.



 Comments   
Comment by Abdelghafour IFTAH [ 10/Oct/13 ]

I solved this problem by adding the following code to : app/config/config.yml

services:
oracle.listener:
class: Doctrine\DBAL\Event\Listeners\OracleSessionInit
tags:

  • { name: doctrine.event_listener, event: postConnect }

This seems to be a bug in Symfony2 DoctrineBundle. If we use the MySQL
driver, the corresponding MysqlSessionInit is loaded properly in the
Dependency Injection extension. But this doesn't happen with the
OracleSessionInit class, if we use the Oracle driver.

I hope someone is going to find this helpful.

Respect,
iftah

Comment by Abdelghafour IFTAH [ 10/Oct/13 ]

I solved this problem by adding the following code to : app/config/config.yml

services:
oracle.listener:
class: Doctrine\DBAL\Event\Listeners\OracleSessionInit
tags:

  • { name: doctrine.event_listener, event: postConnect }

This seems to be a bug in the DoctrineBundle. If we use the MySQL driver, the corresponding MysqlSessionInit is loaded properly in the Dependency Injection extension. But this doesn't happen with the OracleSessionInit class, if you we the Oracle driver.

Generated at Sun Apr 20 03:24:07 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.