Overflow and Numeric Arguments - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantageā„¢

To avoid numeric overflow conditions, the C/C++ function should define a decimal data type as big as it can handle.

If the assignment of the value of an input or output numeric argument would result in a loss of significant digits, a numeric overflow error is reported.

For example, consider an external stored procedure that takes a DECIMAL(2,0) argument:

CREATE PROCEDURE smldec( IN p1 DECIMAL(2,0) )
LANGUAGE C
NO SQL
PARAMETER STYLE SQL
EXTERNAL;

Passing a number with a maximum of two digits is successful:

CALL smldec(99);

An attempt to pass a number larger than 99 or smaller than -99 would result in a loss of significant digits.

CALL smdec(100);
   
 Failure 2616 Numeric overflow occurred during computation.

Any fractional numeric data that is passed or returned that does not fit as it is being assigned is rounded according to the Teradata rounding rules. For more information on rounding, see Teradata Vantageā„¢ - Data Types and Literals, B035-1143.