VARCHAR CHARACTER SET GRAPHIC, LONG VARCHAR CHARACTER SET GRAPHIC - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantageā„¢

C Data Type and Macro Definition

typedef struct VARGRAPHIC {
    int      length;       /* length of string */
    GRAPHIC  graphic[1];   /* string - size must be adjusted */
} VARGRAPHIC;

#define VARGRAPHIC_M(len) struct { int length; GRAPHIC graphic[len]; }

Usage

Use the VARGRAPHIC structure for reference to an existing VARCHAR CHARACTER SET GRAPHIC value.

Use the VARGRAPHIC_M macro to define your own VARCHAR CHARACTER SET GRAPHIC value of specific length. For example, to define a VARCHAR CHARACTER SET GRAPHIC value of length 30, use the macro like this:
VARGRAPHIC_M(30) myvgstr;

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

Here is an example using VARCHAR(n) CHARACTER SET GRAPHIC in a UDF definition and C function declaration.

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