Numeric overflow occurred during computation in Teradata Stored procedure

Database
Enthusiast

Numeric overflow occurred during computation in Teradata Stored procedure

INSERT INTO TGT
SELECT
DECIMAL_C1,
DECIMAL_C2,
MAX(CAST(DATE_C3 AS DATE)) AS MAX_DATE_C3,
MAX(CAST(TIMETSAMP_C4 AS TIMESTAMP(6))) AS MAX_TIMETSAMP_C4
(
    SELECT 
    DECIMAL_C1,
    DECIMAL_C2,
    DATE_C3,
    TIMETSAMP_C4
    FROM TAB_1
    WHERE DATE_C3 < DATE '2016-08-09'
 UNION
    SELECT 
    DECIMAL_C1,
    DECIMAL_C2,
    DATE_C3,
    TIMETSAMP_C4
    FROM TAB_2
) AS SRC
GROUP BY 1,2;

Hi All,

I am executing above piece of code in stored procedure. But while executing getting "Numeric overflow occured during computation error".

If I execute same piece of code in Teradata SQL Assistant then it executes successfully.

whereas in stored procedure I am forming this code using dynamic table names and string concat and executing through dbc.sysexecsql() function but then it logs error as numeric overflow in log table which is maintained for failure.

I have checked datatype for all fields along with precision and everything is in place but still unable to resolve error.

Please help me to resolve the issue.

Thanks in advance!

Priti