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

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
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, 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.