You can create a User Defined Function (UDF) function using a C program and
install it on the Teradata database in order to use regular expressions.
Before you begin
- Retrieve the Regex_INSTR.c file
from the Downloads tab in the left panel of this
page.
Procedure
-
Create a C program like Regex_INSTR.c.
-
Put this C file on your Teradata database.
-
Login to Teradata using the user created previously.
-
Create a UDF function. You can use the following command for example:
CREATE FUNCTION Regex_INSTR (
InputString VARCHAR(4096) CHARACTER SET LATIN,
PatternString VARCHAR(512) CHARACTER SET LATIN )
RETURNS INTEGER
LANGUAGE C
NO SQL
EXTERNAL NAME 'CS!Regex_INSTR!/Regex_INSTR.c!F!Regex_INSTR1'
PARAMETER STYLE SQL;
-
Test the UDF using the following SQL instruction:
select Regex_INSTR('A','[A-Z]');
The instruction
should return 1.