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

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料