FNC_SetVarCharLength Function | C Library Functions | Teradata Vantage - FNC_SetVarCharLength - 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ā„¢

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