VARBYTE - 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™

C Data Type and Macro Definition

typedef struct VARBYTE
{
    int   length;            /* length of string */
    BYTE  bytes[1];          /* bytes - size must be adjusted */
} VARBYTE;
#define VARBYTE_M(len) struct { int length; BYTE bytes[len]; }

Usage

Use the VARBYTE structure for reference to an existing VARBYTE.

Use the VARBYTE_M macro to define your own VARBYTE of specific length. For example, to define a VARBYTE of length 30, use the macro like this:

VARBYTE_M(30) myvbstr;

If the function result type is variable length byte data, then the result argument points to a data area containing a VARBYTE structure with a bytes field reserved to the maximum defined by the RETURNS clause in the CREATE FUNCTION statement.

Here is an example using VARBYTE in a UDF definition and C function declaration.

SQL Function Definition Equivalent C Function Declaration
CREATE FUNCTION F1 (
  A VARBYTE(30) )
RETURNS VARBYTE(12)
 ...;
void f1( VARBYTE *a,
         VARBYTE *result,
   ... )
{  ... }