Rules for Writing UDFs that Decompress Character and Byte Data - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantageā„¢
  • The scalar UDF must declare a single VARBYTE(n) input parameter that matches the length of the VARBYTE(n) return type of the corresponding UDF for compressing the data.
  • The data type of the result parameter must be BYTE(n), VARBYTE(n), CHAR(n), or VARCHAR(n) and must be compatible with the data type of the table column.

    The length of the column must be less than or equal to the length of the result parameter.

    For CHAR and VARCHAR columns, you must use the CHARACTER SET phrase in the parameter declaration to specify a server character set that matches the server character set of the column.

    Recommendation: Declare the result parameter with a data type of VARBYTE(n) or VARCHAR(n). This is best for most situations.

  • If the UDF is for decompressing previously compressed character data, the UDF must call FNC_GetOutputBufferSize to determine the maximum length of the string to build.

    If the UDF return parameter is a CHAR, the UDF must append the necessary pad characters to the result to fill up the buffer. If the column type is VARCHAR, Vantage trims any pad characters.

    If the UDF return parameter is a VARCHAR and the column type is CHAR, Vantage appends any necessary pad characters.