RETURN Statement Usage Notes - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530
  • RETURN is an SQL control statement that can only be run from within an SQL UDF.
  • You cannot specify more than one RETURN statement per SQL UDF.
  • The data type of value_expression must match the data type specified by the RETURNS clause of the SQL UDF definition or be able to be cast implicitly to the data type specified in the RETURNS clause.

    The specified data types can be any valid Teradata type.

  • value_expression cannot contain references to tables.
  • value_expression cannot contain scalar subqueries such as those made by DML statements.
  • value_expression can contain references to parameters, constants, SQL UDFs, external UDFs, and methods.
  • value_expression cannot be a conditional expression or have a Boolean return type.
  • value_expression can contain arithmetic values and functions, string functions, DateTime functions, and SQL operators that define a scalar result.
  • value_expression cannot contain aggregate or ordered analytic functions.
  • If the RETURN statement references an SQL UDF, the reference cannot be any of the following:
    • Self-reference
    • Circular reference
    • Forward reference (reference to another SQL UDF that does not yet exist)