Creating a User Defined Function using a C program - Cloud

Talend Cloud Data Management Platform Studio User Guide

Version
Cloud
Language
English (United States)
Product
Talend Cloud
Module
Talend Management Console
Talend Studio
Content
Design and Development
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

  1. Create a C program like Regex_INSTR.c.
  2. Put this C file on your Teradata database.
  3. Login to Teradata using the user created previously.
  4. 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;
  5. Test the UDF using the following SQL instruction:
    select Regex_INSTR('A','[A-Z]');
    The instruction should return 1.