FNC_SetVarCharLength Function | C Library Functions | Teradata Vantage - 17.10 - FNC_SetVarCharLength - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1147-171K
Language
English (United States)

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);

Syntax Elements

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.
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);
}