IBM Support

Improved Inlining support for SQL Scalar User Defined Functions (UDFs)

News


Abstract

Improved Inlining support for SQL Scalar User Defined Functions (UDFs)

Content

You are in: IBM i Technology Updates > Db2 for i - Technology UpdatesDb2 for i Performance Enhancements > Improved Inlining support for SQL Scalar User Defined Functions (UDFs)

Inline functions: When an SQL scalar function is inlined, instead of invoking the function as part of a query, the expression in the RETURN statement of the function may be copied (inlined) into the query itself. Such a function is called an inline function. A scalar function is an inline function if:
  • The SQL function is global deterministic.
  • The SQL-routine-body contains only a RETURN statement.
  • No input parameter is an array type.
  • The data type of the result is not XML or an array type.
  • All objects referenced in the function exist when the function is created.
  • The SQL-routine-body does not contain a common table expression that references an input parameter.
  • The SQL-routine-body does not contain a nested table expression without a preceding LATERAL keyword that references an input parameter.

An inline function is only copied (inlined) into a query if:

  • The query is eligible for the SQL Query Engine (SQE).
  • The function references an object and the authority attributes of the function and the query are compatible based on one of the following conditions:
    • The function is defined to run under the user's authority (*USER).
    • The query is running under the owner's authority (*OWNER) and the owner of the query is the same as the owner of the function.
    • The query is running under the user's authority (*USER), and the user or the user's group profile is the same as the owner of the function.
    Note: If the function is defined as FENCED, the query must not use adopted authority. If the query runs under the owner's authority (*OWNER) and the function runs under the user’s authority (*USER), the owner of the query must be the same as the user or the user's group profile.

When a function is inlined, some of the options specified when the function was created are ignored:

  • PARALLEL or NOT PARALLEL
  • MODIFIES SQL DATA
  • Commitment control level
  • CONCURRENT ACCESS RESOLUTION
  • ALWCPYDTA
  • ATOMIC or NOT ATOMIC

If a function is inlined and it contains a reference to a special register, the value of the special register will be the same as other references to the same special register in the query.


image-20200116131252-1

image-20200116131306-2

image-20200116131319-3

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Component":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
21 January 2020

UID

ibm11168180