This function accepts the following data types as valid input parameters: CHARACTER, VARCHAR, and CLOB. See Teradata Vantage™ - SQL External Routine Programming , B035-1147 for the C code for the ascii UDF.
The function then returns the numeric representation of the first character in the string_expr parameter according to the ASCII character encoding scheme.
The RETURNS clause type supported by this function is any of the following types: BYTEINT, SMALLINT, and INTEGER.
You can use this function to determine the numeric representation of CHARACTER, VARCHAR or CLOB data without knowing anything about the server character set for the data. The function can also return data requesting it as any of the following types: BYTEINT, SMALLINT or INTEGER.
CREATE FUNCTION ascii ( string_expr TD_ANYTYPE) RETURNS TD_ANYTYPE LANGUAGE C NO SQL SPECIFIC ascii EXTERNAL NAME 'CS!ascii!ascii.c' PARAMETER STYLE SQL;
Because the TD_ANYTYPE parameter type can accept any supported data type, it is not necessary to create separate functions like ascii_char_latin(), ascii_char_unicode(), ascii_varchar_latin(), ascii_varchar_unicode(), ascii_clob_latin(), ascii_clob_unicode(), and so forth to handle multiple parameter data types.