我们是否有任何标准的oracle错误表或任何可识别表中我输入的值大于指定精度的列的东西。ORA-01438: value larger than specified precision allows for this column
-如何获得它指的是哪一列?
最佳答案
我认为您必须编写一个过程并尝试一一更新列。
假设您有这样的更新:
UPDATE TABLE_1 a SET (COL_1, COL_2, COL_3) =
(SELECT COL_1, COL_2, COL_3 FROM TABLE_2 b WHERE a.COL_ID = b.COL_ID);
然后,您可以通过以下方法遍历所有列:
DECLARE
CURSOR TabColumns IS
SELECT column_id, column_name, data_precision, data_scale
FROM USER_TAB_COLUMNS
WHERE table_name = 'TABLE_2'
AND column_name <> 'COL_ID'
ORDER BY 1;
BEGIN
FOR aCol IN TabColumns LOOP
BEGIN
sqlstr :=
'UPDATE TABLE_1 a SET '||aCol.column_name ||' = '
||' (SELECT '||aCol.column_name ||
||' FROM TABLE_2 b '
||' WHERE a.COL_ID = b.COL_ID)'
EXECUTE IMMEDIATE sqlstr USING CalcDate, CalcDate;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ( 'Error at column '|| aCol.column_id||CHR(9)|| aCol.column_name||CHR(9)||SQLERRM);
DBMS_OUTPUT.PUT_LINE ( sqlstr );
END;
END LOOP;
END;
效率不是很高,您应该会看到错误。