17.05 - Example: Invoking an SQL UDF in a Recursive Query - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

This example invokes the SQL UDF value_expression in the WHERE clause of the recursive query.

     WITH RECURSIVE temp_table (employee_number) AS (
       SELECT root.employee_number
       FROM employee AS root
       WHERE root.manager_employee_number = 801
       AND   test.value_expression(dept_no, 0) = 25;
     UNION ALL
       SELECT indirect.employee_number
       FROM temp_table AS direct, employee AS indirect
       WHERE direct.employee_number = indirect.manager_employee_number
       AND   test.value_expression(2,3) = 5
       )
     SELECT *
     FROM temp_table
     ORDER BY employee_number;