Usage Notes - 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 define the buffer pointed to by newValue, use the C data type that maps to the underlying type of the distinct UDT. For example, if the distinct type represents an SQL INTEGER data type, you can define the buffer like this:

INTEGER value;
value = 2048;

For information on the C data types that you can use, see C Data Types.

If the underlying type of the distinct UDT is a character string, and the newValue character string is shorter than the size defined for the type, FNC_SetDistinctValue fills to the right with spaces.

Because character data types allow embedded null characters, do not include null termination characters in the value you pass in for the length argument.

To guarantee that the value you pass in for the length argument matches the length of the data type, use these macros defined in the sqltypes_td.h header file.

Macro Description
SIZEOF_CHARACTER_LATIN(len)
SIZEOF_CHARACTER_KANJISJIS(len)
SIZEOF_CHARACTER_KANJI1(len)
SIZEOF_CHARACTER_UNICODE(len)
Returns the length in bytes of a CHARACTER data type of len characters. For example, the following returns a length of 6 (3 * 2 = 6):
SIZEOF_CHARACTER_UNICODE(3)
SIZEOF_VARCHAR_LATIN(len)
SIZEOF_VARCHAR_KANJISJIS(len)
SIZEOF_VARCHAR_KANJI1(len)
SIZEOF_VARCHAR_UNICODE(len)
Returns the length in bytes of a VARCHAR data type of len characters. For example, the following returns a length of 6 (3 * 2 = 6):
SIZEOF_VARCHAR_UNICODE(3)
SIZEOF_BYTE(len)
SIZEOF_VARBYTE(len)
Returns the length in bytes of the specified BYTE or VARBYTE data type, where len specifies the number of values.
SIZEOF_GRAPHIC(len)
SIZEOF_VARGRAPHIC(len)
Returns the length in bytes of the specified CHARACTER(n) CHARACTER SET GRAPHIC or VARCHAR(n) CHARACTER SET GRAPHIC data type, where len specifies the number of values.
SIZEOF_BYTEINT
SIZEOF_SMALLINT
SIZEOF_INTEGER
SIZEOF_BIGINT
SIZEOF_REAL
SIZEOF_DOUBLE_PRECISION
SIZEOF_FLOAT
SIZEOF_DECIMAL1
SIZEOF_DECIMAL2
SIZEOF_DECIMAL4
SIZEOF_DECIMAL8
SIZEOF_DECIMAL16
SIZEOF_NUMERIC1
SIZEOF_NUMERIC2
SIZEOF_NUMERIC4
SIZEOF_NUMERIC8
SIZEOF_NUMERIC16
SIZEOF_NUMBER
Returns the length in bytes of the specified numeric data type.

For NUMBER, the length returned is 4 + 2 + 17 = 23 bytes since Vantage allocates max length (17 bytes) for the mantissa.

SIZEOF_DATE
SIZEOF_ANSI_Time
SIZEOF_ANSI_Time_WZone
SIZEOF_TimeStamp
SIZEOF_TimeStamp_WZone
Returns the length in bytes of the specified DateTime type.
SIZEOF_INTERVAL_YEAR
SIZEOF_IntrvlYtoM
SIZEOF_INTERVAL_MONTH
SIZEOF_INTERVAL_DAY
SIZEOF_IntrvlDtoH
SIZEOF_IntrvlDtoM
SIZEOF_IntrvlDtoS
SIZEOF_HOUR
SIZEOF_IntrvlHtoM
SIZEOF_IntrvlHtoS
SIZEOF_MINUTE
SIZEOF_IntrvlMtoS
SIZEOF_IntrvlSec
Returns the length in bytes of the specified Interval type.