SQL查出异常数据(ORA-01722: 无效数字)

-- Created on 2015/4/29 by MENGHU 
DECLARE
  -- Local variables here
  I INTEGER;
BEGIN
  FOR OPEN_DATA IN (SELECT *
                      FROM SYS_DEPT_ACCOUNTING SDA
                     WHERE SDA.SEGMENT4 IS NOT NULL) LOOP
    BEGIN
      BEGIN
        SELECT TO_NUMBER(TRIM(SDA.SEGMENT4))
          INTO I
          FROM SYS_DEPT_ACCOUNTING SDA
         WHERE SDA.SEGMENT4 IS NOT NULL
           AND SDA.ACCOUNT_ID = OPEN_DATA.ACCOUNT_ID;
      EXCEPTION
        WHEN OTHERS THEN
          NULL;
          INSERT INTO TEMP_T1 (A1) VALUES (OPEN_DATA.ACCOUNT_ID);
      END;
    END;
  END LOOP;
END;

程序中进行数据转换时报错,需要查出具体的数据是哪条,可以通过以上测试存储过程查询。

posted @ 2015-04-29 15:19  humeng126  阅读(1915)  评论(0编辑  收藏  举报