Example: Creating Functions that Algorithmically Compress LOB-Related Data - Teradata Vantage - Analytics Database

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-06
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
Product Category
Teradata Vantage™

The CREATE FUNCTION requests in this example are written to algorithmically compress various kinds of LOB-related data.

See Teradata Vantage™ - SQL External Routine Programming, B035-1147 for information about how to write the C, C++, or Java code for the external functions these function definitions reference to compress LOB-related data.

You can find the functions written to decompress the data algorithmically compressed by the functions in these examples in Example: Creating Functions that Decompress Algorithmically Compressed LOB-Related Data.

This example creates a UDF named clob_compress to algorithmically compress CLOB columns.

     CREATE FUNCTION clob_compress (a CLOB AS LOCATOR) 
     RETURNS BLOB AS LOCATOR 
     SPECIFIC clob_compress 
     LANGUAGE C 
     NO SQL  
     FOR COMPRESS 
     PARAMETER STYLE TD_GENERAL 
     RETURNS NULL ON NULL INPUT 
     DETERMINISTIC 
     EXTERNAL NAME 'cs!clobcompress!clobcompress.c';

This example creates a UDF named d_clob_compress to algorithmically compress distinct LOB-based UDT columns.

     CREATE FUNCTION d_clob_compress (a DCLOB) 
     RETURNS BLOB AS LOCATOR 
     SPECIFIC d_clob_compress 
     LANGUAGE C 
     NO SQL  
     FOR COMPRESS 
     PARAMETER STYLE TD_GENERAL RETURNS NULL ON NULL INPUT 
     DETERMINISTIC 
     EXTERNAL NAME 'cs!dclobcompress!dclobcompress.c';