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, ... ) { ... } |