FNC_MBRSetValue Function | C Library Functions | Teradata Vantage - FNC_MBRSetValue - 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
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantageā„¢

Set the value of an MBR (minimum bounding rectangle) type using a buffer of four double precision values. The values represent the xmin, ymin, xmax, and ymax coordinates that define the MBR.

Syntax

void
FNC_MBRSetValue(GEO_HANDLE    mbrHandle,
                double *      mbrValue)

Syntax Elements

mbrHandle
A handle to an MBR type that is defined to be a return value for a UDF/UDM or an INOUT/OUT parameter to an external stored procedure.
mbrValue
A pointer to a buffer containing the four double precision values.

Usage Notes

FNC_MBRSetValue sets the value of an MBR type. A buffer mbrValue containing four double precision values is provided as input to the routine along with the MBR handle.

Example: Using FNC calls to set an MBR type value

The following function takes four double precision values as input, and returns an MBR value.

CREATE FUNCTION mbrUDF1(P0 DOUBLE PRECISION, P1 DOUBLE PRECISION, 
                        P2 DOUBLE PRECISION, P3 DOUBLE PRECISION)
RETURNS MBR
NO SQL
PARAMETER STYLE SQL
DETERMINISTIC
LANGUAGE C
EXTERNAL NAME 'CS!mbrUDF1!mbrUDF1.c';

void mbrUDF1 (DOUBLE_PRECISON* p0,
              DOUBLE_PRECISON* p1,
              DOUBLE_PRECISON* p2,
              DOUBLE_PRECISON* p3,
              GEO_HANDLE* resultMBR,
              int* indicator_p0,
              int* indicator_p1,
              int* indicator_p2,
              int* indicator_p3,
              int* indicator_Result,
              char       sqlstate[6],
              SQL_TEXT   extname[129],
              SQL_TEXT   specific_name[129],
              SQL_TEXT   error_message[257] )
{
     double* mbrBuffer;
     int returnSize;
     int mbrBufferSize;

     mbrBufferSize = 4 * SIZEOF_DOUBLE_PRECISION;
     mbrBuffer = (double*)FNC_Malloc(mbrBufferSize);
     /* Set the double precision values in the buffer */
      mbrBuffer[0] = *p0;
      mbrBuffer[1] = *p1;
      mbrBuffer[2] = *p2;
      mbrBuffer[3] = *p3;

      /* Set the MBR value */
       FNC_MBRSetValue(*resultMBR, mbrBuffer); 

     *indicator_Result = 0;
      FNC_free(mbrBuffer);
}