我们是否有任何标准的oracle错误表或任何东西来确定表中哪个列输入的值大于指定的精度.
ORA-01438:大于指定精度的值允许此列 – 如何获取它所指的列?
最佳答案 我认为你必须编写一个过程并尝试逐个更新列.
假设您有这样的更新:
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;
效率不高,你应该看到错误.