ALTER FUNCTION (external table)

The ALTER FUNCTION (external table) statement alters an external table function at the current server.

Invocation

This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.

Authorization

The privileges held by the authorization ID of the statement must include at least one of the following:

  • For the function identified in the statement:
    • The ALTER privilege for the function, and
    • The USAGE privilege on the schema containing the function.
  • Database administrator authority

If a different external program is specified, the privileges held by the authorization ID of the statement must also include the same privileges required to create a new external table function. For more information, see CREATE FUNCTION (external table).

If the SECURED option is specified or if the function is currently secure:

For information about the system authorities corresponding to SQL privileges, see Corresponding System Authorities When Checking Privileges to a Function or Procedure, Corresponding System Authorities When Checking Privileges to a Table or View, and Corresponding System Authorities When Checking Privileges to a Distinct Type.

Syntax

Read syntax diagramSkip visual syntax diagramALTERFUNCTIONfunction-name(,parameter-type)SPECIFIC FUNCTIONspecific-nameALTERRESTRICT option-list
parameter-type
Read syntax diagramSkip visual syntax diagramdata-typeAS LOCATOR
data-type
Read syntax diagramSkip visual syntax diagrambuilt-in-typedistinct-type-name
option-list
Read syntax diagramSkip visual syntax diagramLANGUAGECC++CLCOBOLCOBOLLEJAVAPLIREXXRPGRPGLE PARAMETER STYLE SQLPARAMETER STYLE DB2GENERAL NOT DETERMINISTICDETERMINISTIC1MODIFIES SQL DATAREADS SQL DATACONTAINS SQLNO SQLCALLED ON NULL INPUTRETURNS NULL ON NULL INPUT WITHOUT RESTRICT ON DROPWITH RESTRICT ON DROPINCLUDING EXTERNAL PROGRAM INHERIT SPECIAL REGISTERSSTATIC DISPATCHNO DBINFODBINFOEXTERNAL ACTIONNO EXTERNAL ACTIONFENCEDNOT FENCEDEXTERNAL NAMEexternal-program-nameNO FINAL CALLFINAL CALLALLOW PARALLELDISALLOW PARALLELNO SCRATCHPADSCRATCHPAD100integerCARDINALITYbigintNOT SECUREDSECURED
Notes:
  • 1 The clauses in the option-list can be specified in any order.
built-in-type
Read syntax diagramSkip visual syntax diagramSMALLINTINTEGERINTBIGINTDECIMALDECNUMERICNUM(5,0)(integer,0, integer)FLOAT(53)(integer)REALDOUBLEPRECISIONDECFLOAT(34)(16)CHARACTERCHAR(1)(integer)CHARACTERCHARVARYINGVARCHAR(integer)FOR BIT DATAFOR SBCS DATAFOR MIXED DATAccsid-clauseCHARACTERCHARLARGE OBJECTCLOB(1M)(integerKMG)FOR SBCS DATAFOR MIXED DATAccsid-clauseGRAPHIC(1)(integer)GRAPHIC VARYINGVARGRAPHIC(integer)DBCLOB(1M)(integerKMG)ccsid-clauseNATIONAL CHARACTERNATIONAL CHARNCHAR(1)(integer)NATIONAL CHARACTERNATIONAL CHARNCHARVARYINGNVARCHAR(integer)NATIONAL CHARACTERNCHARLARGE OBJECTNCLOB(1M)(integerKMG)BINARY(1)(integer)BINARY VARYINGVARBINARY(integer)BLOBBINARY LARGE OBJECT(1M)(integerKMG)DATETIME(0)TIMESTAMP(6)(integer)DATALINK(200)(integer)ccsid-clauseROWIDXMLBOOLEAN
ccsid-clause
Read syntax diagramSkip visual syntax diagramCCSIDinteger

Description

FUNCTION or SPECIFIC FUNCTION
Identifies the function to alter. function-name must identify an external table function that exists at the current server. It cannot identify a built-in function, a sourced function, or an SQL function. An external scalar function cannot be altered to be an external table function.

The specified function is altered. The owner of the function is preserved. If the external program or service program exists at the time the function is altered, all privileges on the function are preserved.

FUNCTION function-name
Identifies the function by its name. The function-name must identify exactly one function. The function may have any number of parameters defined for it. If there is more than one function of the specified name in the specified or implicit schema, an error is returned.
FUNCTION function-name (parameter-type,...)
Identifies the function by its function signature, which uniquely identifies the function. The function-name (parameter-type,...) must identify a function with the specified function signature. The specified parameters must match the data types in the corresponding position that were specified when the function was created. The number of data types, and the logical concatenation of the data types is used to identify the specific function instance which is being altered. Synonyms for data types are considered a match. Parameters that have defaults must be included in this signature.

If function-name() is specified, the function identified must have zero parameters.

function-name
Identifies the name of the function.
(parameter-type,...)
Identifies the parameters of the function.

If an unqualified distinct type name is specified, the database manager searches the SQL path to resolve the schema name for the distinct type.

For data types that have a length, precision, or scale attribute, use one of the following:

  • Empty parenthesis indicates that the database manager ignores the attribute when determining whether the data types match. For example, DEC() will be considered a match for a parameter of a function defined with a data type of DEC(7,2). However, FLOAT cannot be specified with empty parenthesis because its precision value indicates a specific data type (REAL or DOUBLE).
  • If a specific value for a length, precision, or scale attribute is specified, the value must exactly match the value that was specified (implicitly or explicitly) in the CREATE FUNCTION statement. If the data type is FLOAT, the precision does not have to exactly match the value that was specified because matching is based on the data type (REAL or DOUBLE).
  • If length, precision, or scale is not explicitly specified, and empty parentheses are not specified, the default attributes of the data type are implied. The implicit length must exactly match the value that was specified (implicitly or explicitly) in the CREATE FUNCTION statement.

Specifying the FOR DATA clause or CCSID clause is optional. Omission of either clause indicates that the database manager ignores the attribute when determining whether the data types match. If either clause is specified, it must match the value that was implicitly or explicitly specified in the CREATE FUNCTION statement.

AS LOCATOR
Specifies that the function is defined to receive a locator for this parameter. If AS LOCATOR is specified, the data type must be a LOB or XML or a distinct type based on a LOB or XML.
SPECIFIC FUNCTION specific-name
Identifies the function by its specific name. The specific-name must identify a specific function that exists at the current server.
ALTER option-list
Indicates that one or more of the options of the function are to be altered. If an option is not specified, the value from the existing function definition is used. See CREATE FUNCTION (external table) for a description of each option.
RESTRICT
Indicates that the function will not be altered if it is referenced by any view, function, procedure, or materialized query table.

Notes

General considerations for defining or replacing functions: See CREATE FUNCTION (external table) for general information about defining a function. ALTER FUNCTION (external table) allows individual attributes to be altered while preserving the privileges on the function.

Altering a function from NOT SECURED to SECURED: The function is considered secure after the ALTER FUNCTION statement is executed. Db2® treats the SECURED attribute as an assertion that declares that the user has established an audit procedure for all changes to the user-defined function. Db2 assumes that all subsequent ALTER FUNCTION statements are being reviewed through this audit process.

Invoking other user-defined functions in a secure function: When a secure user-defined function is referenced in an SQL data change statement that references a table that is using row access control or column access control, and if the secure user-defined function invokes other user-defined functions, the nested user-defined functions are not validated as secure. If those nested functions can access sensitive data, a user authorized to the Database Security Administrator function of IBM® i needs to ensure that those functions are allowed to access that data and should ensure that a change control audit procedure has been established for all changes to those functions.

Syntax alternatives: The following keywords are synonyms supported for compatibility to prior releases. These keywords are non-standard and should not be used:

  • The keywords VARIANT and NOT VARIANT can be used as synonyms for NOT DETERMINISTIC and DETERMINISTIC.
  • The keywords NULL CALL and NOT NULL CALL can be used as synonyms for CALLED ON NULL INPUT and RETURNS NULL ON NULL INPUT.
  • The keyword DB2GENRL may be used as a synonym for DB2GENERAL.
  • The value DB2SQL may be used as a synonym for SQL.
  • The keywords PARAMETER STYLE in the PARAMETER STYLE clause are optional.
  • The keywords IS DETERMINISTIC may be used as a synonym for DETERMINISTIC.

Example

Modify the definition for an external table function to set the estimated cardinality to 10,000.

  ALTER FUNCTION GET_TABLE 
    ALTER CARDINALITY 10000