FNC_SetVarCharLength Function | C Library Functions | Teradata Vantage - FNC_SetVarCharLength - 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™

Purpose

Sets the length, in bytes, for an external stored procedure output parameter or the result of a UDF or UDM that has a VARCHAR data type.

Syntax

void
FNC_SetVarCharLength(void *outputString,
                     int   outputStringLength);
void *outputString
a pointer to an external stored procedure output parameter or the result of a UDF or UDM that has a data type of VARCHAR.
int outputStringLength
the length of the string pointed to by outputString.

Usage Notes

Normally, the database uses strlen to determine the length of an external routine output parameter or result. If the output string contains NULLs, you can use FNC_SetVarCharLength to explicitly set the length of the output string. If you call FNC_SetVarCharLength, the database does not use strlen to get the length of an external routine output parameter or result.

Undefined results occur if the outputString argument points to data that is not VARCHAR or if outputStringLength is an incorrect length.

Example Using FNC_SetVarCharLength

#define SQL_TEXT Latin_Text
#include "sqltypes_td.h"

void dstrrev13(VARCHAR_LATIN *input,
               int            inplen,
               VARCHAR_LATIN *result)
{
   int i;
   for (i=0; i< inplen; i++)
      result[inplen-i-1] = input[i];
}

void strrevdecomp_varchar(VARBYTE       *InputValue,
                          VARCHAR_LATIN *ResultValue,
                          char           sqlstate[6])
{
   dstrrev13(InputValue->bytes, InputValue->length, ResultValue);
   FNC_SetVarCharLength(ResultValue,InputValue->length);
}