C Aggregate Function Using LOBs | UFC Code Examples | Teradata Vantage - 17.10 - C Aggregate Function Using LOBs - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL External Routine Programming

Advanced SQL Engine
Teradata Database
Release Number
Release Date
July 2021
Content Type
Programming Reference
Publication ID
English (United States)

This example implements the MAX_BLOB aggregate function and illustrates the use of persistent object references (LOB_REF).

Like the standard MAX aggregate function, it returns the greatest BLOB value of the given set. The comparison rule is the same as for VARBYTE or BYTE type values; that is, trailing zeros are not significant.

The algorithm assumes that the objects to be compared are random-valued byte strings. A complete ordering of a pair of strings can be determined by examining the first unequal byte pair.

In the vast majority of cases, the first unequal byte pair can be found within the first PREFIX_SIZE (500) bytes. By saving the prefix of the winner of each comparison, the need to reread any object is rare.