17.10 - Example: Creating Functions that Decompress Algorithmically Compressed LOB-Related Data - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1144-171K
Language
English (United States)

The functions in these examples are designed to decompress LOB-based data that has been algorithmically compressed by the examples in “Example: Creating Functions that Algorithmically Compress 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 decompress LOB-related data.

This example creates a UDF named clob_decompress to decompress CLOB columns that were algorithmically compressed using the function clob_compress from Example: Creating Functions that Algorithmically Compress LOB-Related Data.

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

This example creates a UDF named d_clob_decompress to decompress distinct LOB-based UDT columns that were algorithmically compressed using the function d_clob_compress from Example: Creating Functions that Algorithmically Compress LOB-Related Data.

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

This example creates a UDF named s_clob_decompress to decompress distinct LOB-based UDT columns that were algorithmically compressed using the function s_clob_compress from Example: Creating Functions that Algorithmically Compress LOB-Related Data.

     CREATE FUNCTION s_clob_decompress (a BLOB AS LOCATOR) 
     RETURNS SCLOB 
     SPECIFIC s_clob_decompress 
     LANGUAGE C 
     NO SQL  
     FOR DECOMPRESS 
     PARAMETER STYLE TD_GENERAL RETURNS NULL ON NULL INPUT 
     DETERMINISTIC 
     EXTERNAL NAME 'cs!sclobdecompress!sclobdecompress.c';