Numeric overflow occurred during computation teradata ошибка

I am having an issue with a calculation in one of my Teradata queries. I am multiplying two numbers by each other but i am getting a «Numeric overflow occurred during computation.» error when running the query. I ran a type on both fields and they are DECIMAL(18,15) and DECIMAL(18,9). I tried casting them both to DECIMAL(18,18) when i do the division but its still throwing errors. Here is the calculation. UNITS is the 18,15 and PRICE is the 18,9. Can anyone please give me any tips on how to resolve this?

cast(UNITS as DECIMAL(18,18))* cast(PRICE as DECIMAL(18,18)) as  NEW_CALC

Thanks,

Craig

asked May 13, 2015 at 16:50

craigtb's user avatar

You use wrong datatypes, a DECIMAL(18,15) means 18 digits, 15 of them fractional, so the maximum value is 999.999999999999999.

And when you multiply two decimals, the number of fractional digits adds up, NEW_CALC results in 38 fractional digits. Do a TYPE(cast(UNITS as DECIMAL(18,18))* cast(PRICE as DECIMAL(18,18))).

This will work:

cast(UNITS as DECIMAL(38,15))* PRICE

But you better change the column’s datatype to something like (18,2) or (18,4), I don’t think anyone uses more than 4 digits for prices.

answered May 13, 2015 at 17:06

dnoeth's user avatar

dnoethdnoeth

59.4k4 gold badges38 silver badges56 bronze badges

1

Loading Application…

Tracking Consent

PDFs
Site Feedback
Help

Problem

Error Message: Stream execution complete, Elapsed=3637,2 sec, CPU=0,22 sec 22003[-2616] [NCR][ODBC Teradata Driver][Teradata Database] Numeric overflow occurred during computation.

Resolving The Problem

This problem has been reported to SPSS Development

This problem is scheduled to be fixed in the 14.0.2 patch and the 14.1 release

Related Information

[{«Product»:{«code»:»SS3RA7″,»label»:»IBM SPSS Modeler»},»Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Component»:»Modeler»,»Platform»:[{«code»:»PF002″,»label»:»AIX»},{«code»:»PF010″,»label»:»HP-UX»},{«code»:»PF016″,»label»:»Linux»},{«code»:»PF027″,»label»:»Solaris»},{«code»:»PF033″,»label»:»Windows»}],»Version»:»13.0″,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}}]

In Teradata normally we come across this error while selecting column value which is too large to be accommodated in requested datatype.

 In below example we tried to count a  table which has more than 6 billion records, so certainly the count would return result in integer and Standard max value for integer data type is 2147483647. so whenever selected value exceeds this range it will throw this error.

select count(*)  from bm_tb.cust_priscription;

SELECT Failed. 2616: Numeric overflow occurred during computation. 


In this case to get the proper result we need to cast the returned integer value to float or decimal.

select count(*)  (float) from bm_tb.cust_priscription;

6,806,668,046.00

Or

select count(*)  (DECIMAL(12,0))  from bm_tb.cust_priscription;

6,806,668,046

You can try this demo to understand integer limit in SQLA:

SELECT CAST( 2147483647 AS INT)

Result: 2147483647

Then try to select integer value greater than the integer limit.

SELECT CAST( 2147483648 AS INT)

Result: «SELECT Failed. 2616: Numeric overflow occurred during computation.»

@oapa

Encountered a Teradata numeric overflow error below when trying to run «count» validation on a table.  According to this post, it looks like count(*) can overflow on Teradata since it implicitly casts to INT.

pandas.io.sql.DatabaseError: Execution failed on sql 'SELECT count(*) AS "count", count("id") AS "count__id",
 ......
FROM {td_schema}.{td_table}
SAMPLE 10000': [Version 17.0.0.8] [Session 31075829] [Teradata Database] [Error 2616] Numeric overflow occurred during computation

@dhercher

To summarize the issue which is occurring: Teradata implicitly casts any COUNT to INT. Running a normal count could be written more verbosely as
SELECT CAST(COUNT(*) AS INT) AS "count" ...

The overflow does not occur during the count, but rather during the cast which implicitly happens. There are Teradata configs which could override this behavior on a per installation basis (in TD15.10 there’s a new dbscontrol flag to change the default to BIGINT or NUMBER).

We should likely automatically CAST all Teradata COUNT operations to BIGINT or NUMBER to avoid the error

@ryanmcdowell
ryanmcdowell

added

type: bug

Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

priority: p1

Medium priority. Fix may be included in the next release.

labels

Mar 22, 2021

@freedomofnet
freedomofnet

added

priority: p2

Low priority. Fix may not be included in next release (e.g. minor documentation, cleanup)

and removed

Beta

priority: p1

Medium priority. Fix may be included in the next release.

labels

Mar 25, 2021

@freedomofnet
freedomofnet

added

Beta

priority: p1

Medium priority. Fix may be included in the next release.

and removed

priority: p2

Low priority. Fix may not be included in next release (e.g. minor documentation, cleanup)

labels

Jul 1, 2021

@nehanene15

This is now possible with the --cast-to-bigint flag and via YAML. This will cast any int32 columns to int64 before running an aggregation. Closed with PR #461

Понравилась статья? Поделить с друзьями:
  • Noritsu 3201 ошибка 6136 0001
  • Num ошибка обработки rutor lib
  • Nordson problue 10 ошибка f3
  • Null ошибкой на миллиард долларов
  • Nonetype object has no attribute text ошибка