Rules for Invoking a Scalar UDF From a MERGE Request - Teradata Database

SQL Data Manipulation Language

Product
Teradata Database
Release Number
15.10
Language
English (United States)
Last Update
2018-10-06
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata® Database

Rules for Invoking a Scalar UDF From a MERGE Request

You can invoke a scalar UDF from the following clauses of a MERGE request.

  • SELECT
  • You can invoke a scalar UDF from the USING SELECT clause of a MERGE request.

    The rules for this invocation are the same as those for a standalone SELECT request (see “Invoking a Scalar UDF From a SELECT Statement” on page 19.

  • ON
  • You can invoke a scalar UDF from the ON clause of a MERGE request as a secondary condition if it is invoked within an expression within the specified search condition or in the primary condition when it is bound to the primary index.

    The other rules that are applicable to the ON clause of a SELECT request are applicable to the ON clause of a MERGE request. See “SELECT” on page 8 and “Chapter 2 Join Expressions.”

  • UPDATE … SET
  • You can invoke a scalar UDF from the right-hand side of the SET clause in an UPDATE request as long as the UDF always return a value expression.

  • INSERT … VALUES
  • You can invoke a scalar UDF from the VALUES clause of the INSERT specification of a MERGE request.

    The rules for specifying a scalar UDF in the VALUES clause of an INSERT specification are as follows:

  • The arguments passed to a scalar UDF are restricted to the following categories:
  • Constants
  • Parameters that resolve to a constant
  • USING values
  • The scalar UDF must always return a value expression.