Numeric overflow during max function

General
Enthusiast

Numeric overflow during max function

We have an target live table(TARGET) with huge set of columns in which one column is,

SEQ_NO with its datatype as decimal(12,0) and max value present in that table is, 19,880,827,942

 

Now my requirement is to take the max(seq_no) from this TARGET table and put into an existing PARAM table. But the problem here is, the existing param table has only one column with Integer. And I am supposed to put max(seq_no) from target live table to existing param table's column with integer datatype.

 

So, When I give update statement as below,

SyntaxEditor Code Snippet

UPDATE PRM
FROM PARAM_TBL PRM,
(SEL MAX(SEQ_NO) SEQ_NO FROM TGT_TBL) TGT
SET PRM.INT_COL=TGT.SEQ_NO

Getting error as, Numeric overflow occurs during computation.

 

I will not be able to change the datatype of any existing tables. Even, I tried casting the max(seq_no) to decimal/bigint, but still getting the same error.

2 REPLIES
Junior Contributor

Re: Numeric overflow during max function

There's no way to fit 19,880,827,942 into a datatype with a maximum value of 2,147,483,647.

Highlighted
Enthusiast

Re: Numeric overflow during max function

Yes, thanks Dnoeth! Trying an alternative way to store the value in a variable instead of storing in a table.