16.20 - C Function Definition - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
April 2020
Content Type
Programming Reference
Publication ID
B035-1147-162K
Language
English (United States)
#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
#include <string.h>
/* return a pointer to the SQLSTATE string */
void *Find_Text(VARCHAR_LATIN *searched_string,
                VARCHAR_LATIN *pattern,
                CHARACTER_LATIN  *result,
                char  sqlstate[6])
{
  int pattern_found = 0;
  if (strlen((char *)pattern) == 0)
  {
      /* send a warning because probably a mistake */
      *result = 'T';
      strcpy(sqlstate, "01H01"); /* see SQLSTATE table */
      return;
  }
  /* do the pattern match -- code not shown */
  ...
  if (pattern_found)
      *result = 'T';
  else
      *result = 'F';
  /* SQLSTATE is initialized to zero so normal return does */
  /* not need to set it */
  return;
}