dongmei1911 2014-04-16 08:30
浏览 141
已采纳

Symfony2 Doctrine2 Oracle数据库NUMBER DEFAULT类型?

I have a problem, I migrated an application from Symfony 1.4 to Symfony 2.4. I had some troubles getting a decimal variable working. I ended up updating the database with another type but now that I have to use the old production Oracle Database, Doctrine2 tells me I cannot update a field type if there is data in it.

The data it stores is 0.1 or 0.5 or 1.0

In Oracle, the DATA_TYPE is "NUMBER"

    CREATE TABLE "APPRENTICE"."APPRENTICE_YEARTYPE" 
   (    "ID" NUMBER(20,0), 
    "NAME" VARCHAR2(255 BYTE), 
    "ROUNDNUMBER" NUMBER DEFAULT NULL
   ) SEGMENT CREATION IMMEDIATE

When I export the old database with the Symfony2 command, the datatype in Doctrine is Integer... I cannot have decimals with an int. When I try to change the type to decimal with a scale of 2, I get the error that I cannot change the type.

The generated Doctrine2 code :

/**
 * @var integer
 *
 * @ORM\Column(name="ROUNDNUMBER", type="integer", nullable=false)
 */
private $roundnumber;

The Doctrine1 schema :

ApprenticeYeartype:
  columns:
    id:                  {type: integer, notnull: true, primary: true, autoincrement: true}
    name:                {type: string(255), notnull: true}
    roundNumber:         {type: float, notnull: true}

If I try to set the Doctrine2 value to float and update, I get the following error :

 [Doctrine\DBAL\DBALException]
 An exception occurred while executing 'ALTER TABLE APPRENTICE_YEARTYPE MODI
 FY (ROUNDNUMBER  DOUBLE PRECISION DEFAULT NULL)':

 ORA-01440: column to be modified must be empty to decrease precision or sca
 le






 [Doctrine\DBAL\Driver\OCI8\OCI8Exception]
 ORA-01440: column to be modified must be empty to decrease precision or sca
 le

I'm stuck with this, anyone can help ?

Regards

  • 写回答

1条回答 默认 最新

  • dongque6377 2014-05-02 12:10
    关注

    Finally, I changed the Doctrine type to "Decimal, precision 2, scale 1'.

    I manually updated the Oracle type to NUMBER(2,1).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog