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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?