Example Query - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

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 RGS.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;