当前位置: 代码迷 >> Informix >> 请问个informix的类型转换有关问题
  详细解决方案

请问个informix的类型转换有关问题

热度:2682   发布时间:2013-02-26 00:00:00.0
请教个informix的类型转换问题
有个字段type smallint 存储的值有0,1,2 这三种,现在需要把type转为char[40] ,并且需要对原先数据进行转换。
   
  原type=0,新type[1]=1 (下标为数据库里的绝对位置,下同)
原type=1,新type[2]=1
原type=2,新type[3]=3
  请知道的给个语句,或者有链接的也给下

------解决方案--------------------------------------------------------
try:
update tt set type=to_char(case type when 0 then 1 when 2 then 3 end )
------解决方案--------------------------------------------------------
一般做这种转换
1,建立新例
2,把旧例的值改成新例的值
3,检查下数据符合
4,删掉旧列
5,把新列名改成旧列名

要注意的是建表是考虑到各种可能,建好了改,很多东西要改,很麻烦的。

下面的没看懂:
原type=0,新type[1]=1 (下标为数据库里的绝对位置,下同)
原type=1,新type[2]=1
原type=2,新type[3]=3
  相关解决方案