Skip to Main Content
  • Questions
  • ORA-01438: value larger than specified precision allowed for this column

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Alok.

Asked: June 13, 2020 - 4:53 pm UTC

Last updated: June 16, 2020 - 2:29 am UTC

Version: sql

Viewed 10K+ times! This question is

You Asked

Dear Sir,

Interviwer ask to me if i get this error ora-01438 that is "ORA-01438: value larger than specified precision allowed for this column"
then how to find out which column size is not match if table have 150 column and all column data type is number.

Please suggest me.

thank you....

and Connor said...

Yeah, that is a bit of a nasty question :-) because its well known that Oracle does not reveal the column name for number datatypes.

I suspect the intent of this interview question was to get you talking about how to tackle it...so some ideas would be:

1) If its a simple literal statement, you can use DBMS_SQL to get the column in error

SQL> create table t
  2   ( x number(2),
  3     y number(3),
  4     z number(4)
  5   );

Table created.

SQL>
SQL> insert into t values (123,123,123);
insert into t values (123,123,123)
                      *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL>
SQL> set serverout on
SQL> declare
  2    c   integer := dbms_sql.open_cursor ();
  3    erg integer;
  4    l_sql varchar2(4000) := 'insert into t values (123,123,123)';
  5  begin
  6    dbms_sql.parse (c, l_sql, dbms_sql.native);
  7    erg := dbms_sql.execute(c);
  8    dbms_sql.close_cursor (c);
  9  exception
 10    when others then
 11      dbms_output.put_line(sqlerrm);
 12      dbms_output.put_line(l_sql);
 13      dbms_output.put_line(lpad('^', dbms_sql.last_error_position+1,'='));
 14      dbms_sql.close_cursor (c);
 15  end;
 16  /
ORA-01438: value larger than specified precision allowed for this column
insert into t values (123,123,123)
======================^

PL/SQL procedure successfully completed.


2) In a more realistic scenarios, the values aren't known in advance. For that one, a SQL trace to capture binds can assist, eg

exec dbms_monitor.session_trace_enable(binds=>true)
[run sql]


The trace file contains each bind variable value and that can be compared to the datatype sizes for each column



Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, June 15, 2020 - 8:38 am UTC

dbms_errlog.create_error_log to the rescue :)
Connor McDonald
June 16, 2020 - 2:29 am UTC

Agreed, but that means editing the source SQL statement.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library