ORA-01438: value larger than specified precision allows for this column - How do i get which column it is referring to? ORA-01438: value larger than specified precision allows for this column - How do i get which column it is referring to? oracle oracle

ORA-01438: value larger than specified precision allows for this column - How do i get which column it is referring to?


I think you have to write a procedure and try to update the column one by one.

Let's say you have an update like this:

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);

Then you can loop over all columns by this:

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;    

Not very efficient you should see the error.


If you're doing an INSERT, create a view based on the query or values (SELECT FROM DUAL) you're inserting. Then DIFF the view with the table you're inserting into. You ought to be able to find where the data types do not match in size/precision/scale.