How to resolve the numeric overflow error in Teradata

Numeric Datatypes in Teradata

Teradata provides the multiple numeric data types for the columns and it is listed below

  • Byte Int – Represents a signed binary integer value in the range -128 to 127.
  • Small Int – Represents a signed binary integer value in the range -32768 to 32767.
  • Integer  – Represents a signed, binary integer value from -2,147,483,648 to 2,147,483,647.
  • Big Int – Represents a signed, binary integer value from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
  • Float/Double – Represent values in sign/magnitude form ranging from 2.226 x 10-308 to 1.797 x 10308.
  • Number – Represents a numeric value with optional precision(range is from 1 to 38) and scale limitations. 
  • Decimal – Represents a decimal number of n digits( range is from 1 through 38), with m(the number of fractional digits) of those n digits to the right of the decimal point.

Numeric overflow error (code = 2616) in Teradata

If we try to insert the larger values than the allowed/specified size of the numeric column, Teradata will throw the numeric overflow error. Lets see the numeric overflow error for Decimal column with example.

Example : Target table ==> Banking_DB.Customer

Here the customer table is created in the Banking database. The table contains a column as Login_count that specified to Decimal(8,0). If we try to insert the value more than 8 digits for Login_count, It will throw the Numeric overflow error.Initially the table contains the two records as below.

Customer table in Teradata
Customer table in Teradata

Example : Source table ==> Banking_DB.Customer_old

The source table Customer_old contains the old and new customer details with login count. The structure and the values of the table has mentioned below.

Old customer table in Banking database
Old customer table in Banking database

The insert query is trying to select and insert the record with the login count as 18292892 + 19292929982 for the customer id=455. Since the login count value is exceeds the 8 digits during computation in the SELECT CASE statement, it is throwing the numeric overflow error as below.

Output of the insert statement

*** INSERT Failed 2616 Numeric overflow occurred during computation. ***

Resolution: Up size the decimal column in Teradata

We can up size the Login_count column from Decimal(8,0) to Decimal(38,0) in the Target table that will resolve the numeric overflow error during computation.Lets up size the column in Customer table and run the insert query again

The record for cust_id=455 has inserted into the customer table and it contains the Login_count value with more than 8 digits.

Target table: Customer in Banking database
Target table: Customer in Banking database

Recommended Articles