16.20 - Rules for Writing UDFs that Decompress Character and Byte Data - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Advanced SQL Engine
Teradata Database
Release Number
Release Date
April 2020
Content Type
Programming Reference
Publication ID
English (United States)
  • 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, Teradata Database trims any pad characters.

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