17.10 - Example Query - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1147-171K
Language
English (United States)

Here is a sample of how to invoke the table function with constant expression input arguments:

SELECT *
FROM TABLE (extract_field('25,2:9005,7896,9004,7839;36,1:737,9387;',
    25)) AS t1;

Here is a sample of how to invoke the table function using the columns from a derived table as input arguments:

SELECT DISTINCT cust.Customer_ID, cust.Item_ID
FROM raw_cust,
     TABLE (extract_field(raw_cust.pending_data, 25))
AS cust
WHERE raw_cust.region = 1;

Here is the definition of the raw_cust table:

CREATE SET TABLE raw_cust ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT
     (
      region INTEGER,
      pending_data VARCHAR(32000) CHARACTER SET LATIN NOT CASESPECIFIC)
PRIMARY INDEX ( region );

Here is a sample of the data in the raw_cust table:

     region pending_data
----------- ---------------------------------------------------------
          2 7,2:879,3788,879,4500,390,9004;08,1:500,9056;
          1 25,3:9005,3789,9004,4907,398,9004;36,2:738,9387,738,9550;
          1 25,2:9005,7896,9004,7839;36,1:737,9387;