Accessing the Value of a Period Argument - 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™

To access the value of a Period type argument, follow these steps:

  1. Allocate a buffer that is large enough to hold the beginning and ending bounds of the Period type, as represented by the C data type that maps to the SQL element type.

    For example, consider a CREATE FUNCTION statement that specifies a PERIOD(TIME WITH TIME ZONE) argument. To access the value of the argument, the function must allocate a buffer that is large enough to hold two ANSI_Time_WZone values, where ANSI_Time_WZone is the C data type that maps to TIME WITH TIME ZONE.

  2. Call FNC_GetInternalValue to place the value of the Period type into the buffer you allocated.

For detailed information on FNC_GetInternalValue, see C Library Functions.

Here is a code excerpt that shows how to access the value of a PERIOD(DATE) type:

void check_duration( PDT_HANDLE    *duration,
                     INTEGER       *result,
                     char           sqlstate[6])
{
    void * tmpBuf = 0;
    int bufSize = 0;
    int length;
    /* Get the value of the PERIOD(DATE) duration. */
    bufSize = SIZEOF_DATE * 2;
    tmpBuf = FNC_malloc(bufSize);
    FNC_GetInternalValue(*duration, tmpBuf, bufSize, &length);
    ...
}