FNC_GetGeometryInfo Function | C Library Functions | Teradata Vantage - FNC_GetGeometryInfo - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
qnu1472247494689
lifecycle
latest
Product Category
Teradata Vantageā„¢

Returns information about the ST_Geometry value, including its size and whether the function stores its value as a LOB.

Syntax

void FNC_GetGeometryInfo(GEO_HANDLE  geoHandle, 
                         FNC_GeomSize_t *maxLength, 
                         int *numLobs)

Syntax Elements

geoHandle
A handle to an ST_Geometry type that is defined to be an input or output parameter to an external routine.
maxLength
The maximum length possible for this ST_Geometry value.
numLobs
If this ST_Geometry object stores its value as a LOB, numLobs is 1, otherwise numLobs is 0.

Usage Notes

FNC_GetGeomInfo returns information about the ST_Geometry value, such as its maximum size and whether its value is stored in a LOB. The GEO_HANDLE for the ST_Geometry value is passed in as input, and the maximum size and whether the function can store its value as a LOB is returned to the caller.

Example: Using FNC_GeomGetWKT to retrieve a ST_Geometry WKT

The following example function takes a ST_Geometry parameter and retrieves the Well Known Text format for the geometry. It returns the string back in the ST_Geometry return parameter.

CREATE FUNCTION geomUDF1(P1 st_geometry(1000))
RETURNS ST_GEOMETRY(1000)
NO SQL
PARAMETER STYLE SQL
DETERMINISTIC
LANGUAGE C
EXTERNAL NAME 'CS!geomUDF1!geomUDF1.c';

void geomUDF1(GEO_HANDLE* geom_handle,
              GEO_HANDLE* return_handle,
              int* indicator_thisGeom,
              int* indicator_returnGeom,
              char  sqlstate[6],
              SQL_TEXT   extname[129],
              SQL_TEXT   specific_name[129],
              SQL_TEXT   error_message[257] )
{
    FNC_GeomSize_t geomsize;
    FNC_GeomSize_t wktSize;
    char* wktBuffer;
    FNC_GeomSize_t wktBufferSize;
    int srid , max_length, numLobs;

    /* Get the Geometry Info */
     FNC_GetGeometryInfo(*geom_handle,&max_length, &numLobs); 
    if(numLobs == 0)
    {
    /* Get the Geometry WKT Size */
     geomsize = FNC_GeomGetWKTSize(*geom_handle); 

     /* Allocate the buffer to hold the WKT. Note that we add 
        1 for the null termination character. */ 
    wktBuffer = (char*)FNC_Malloc(geomsize + 1);
    wktBufferSize = geomsize + 1;

    /* Get the WKT string */
     FNC_GeomGetWKT(*geom_handle,wktBuffer, wktBufferSize, 
                     &wktSize, &srid); 
                                                                                                   
    /* Set the WKT string as return value */
     FNC_GeomSetWKT(*return_handle, wktBuffer, wktSize,0); 
    *indicator_returnGeom = 0;
    FNC_free(wkbBuffer);
    }
}