Example: TD_ANYTYPE - Teradata Vantage - Analytics Database

SQL Data Types and Literals

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-06
dita:mapPath
uds1628112204571.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
exs1472253032394
lifecycle
latest
Product Category
Teradata Vantage™

Consider the following function definition:

CREATE FUNCTION ascii (string_expr TD_ANYTYPE)
   RETURNS TD_ANYTYPE
   LANGUAGE C
   NO SQL
   SPECIFIC ascii
   EXTERNAL NAME 'CS!ascii!UDFs/ascii.c'
   PARAMETER STYLE SQL;
This function returns the ASCII numeric value of the first character of the input string. It accepts input strings with the following data types:
  • CHARACTER
  • VARCHAR
  • CLOB
  • UDT with a CHARACTER, VARCHAR, or CLOB attribute.
  • ARRAY with an element type of CHARACTER or VARCHAR.

The function accepts the character set associated with the input string. If no character set is explicitly specified, the default character set is used.

The return type supported by this function is BYTEINT, SMALLINT, or INTEGER. To specify the desired return type for the function, use the RETURNS data type or RETURNS STYLE column expression clause when invoking the function.

The following is a sample query that invokes this function:

SELECT (ascii('hello') RETURNS INTEGER);

The output returned by the query is:

ascii('hello')
--------------
           104

For more details about this function, including the corresponding C code example for the function, see Teradata Vantage™ - SQL External Routine Programming, B035-1147.