数据类型不一致引发的问题

1236阅读 0评论2008-04-16 aqcjsy1
分类:Oracle

数据类型不一致引发的问题
执行以下SQL后,报ORA-01722: invalid number
select distinct serial_number,
            to_char(first_fire_date,'mm-dd-yyyy') first_fire_date,
            cis.installation_engineer,
            cis.technology,
            customer_name,
            CCS.site_nm,
            email_id
       from CTSV_INSTALL_SCHEDULE    cis,
            CTSV_RFR_RED_FLAG_REVIEW crrfr,
            ctst_customer_site       ccs,
            prty                     p
      where CRRFR.UNIT_NUMBER =
            DECODE(CIS.SERIAL_NUMBER,
                   'NON-US',
                   CIS.ALTERNATE_SERIAL_NUMBER,
                   CIS.SERIAL_NUMBER)
        AND FIRST_FIRE_STATUS <> 'RELEASE'
        and first_fire_date between sysdate and sysdate + 14
        and ccs.unit_number_id = cis.unit_number
        and DECODE(p.lst_nm, NULL, p.frst_nm, p.lst_nm || ', ' || p.frst_nm) =
            cis.installation_engineer
         order by serial_number;
把sysdate + 14改为13后,却能正确执行,而且测试过sysdate + 13+7/24,也正确,输出sysdate + 13+7/24后,报错时刚好到4月29号0时。而且过了几分钟后,sysdate + 13+7/24也开始报错,因为到了下一个小时。
开始以为是sysdate + 14的问题。经过一步一步的删除where中的条件后,最后发现问题在ccs.unit_number_id = cis.unit_number,左边是number类型的,右边是varchar2类型的,因此某些数据转不过去,而且因为这些数据中又有某些条件刚好满足在4月29号0时,因此发生了错误ORA-01722: invalid number。
上一篇:自定义type类型过小引发的问题
下一篇:metalink关于ORA-01001: invalid cursor的解释