This form of the GRANT statement grants privileges on a function or procedure.
This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.
The privileges held by the authorization ID of the statement must include at least one of the following:
If WITH GRANT OPTION is specified, the privileges held by the authorization ID of the statement must include at least one of the following:
.-PRIVILEGES-. >>-GRANT--+-ALL--+------------+-+--ON---------------------------> | .-,-----------. | | V | | '---+-ALTER---+-+-----' '-EXECUTE-' .-,-----------------------------------------------------------------------. V | >----+-+-+-FUNCTION-+--function-name--+------------------------------+-+---+-+--> | | '-ROUTINE--' '-(--+--------------------+--)-' | | | | | .-,--------------. | | | | | | V | | | | | | '---parameter-type-+-' | | | '-SPECIFIC--+-FUNCTION-+--specific-name-------------------------' | | '-ROUTINE--' | '-+-+-PROCEDURE-+--procedure-name--+------------------------------+-+-' | '-ROUTINE---' '-(--+--------------------+--)-' | | | .-,--------------. | | | | V | | | | '---parameter-type-+-' | '-SPECIFIC--+-PROCEDURE-+--specific-name--------------------------' '-ROUTINE---' .-,----------------------. V | >--TO----+-authorization-name-+-+--+-------------------+------->< '-PUBLIC-------------' '-WITH GRANT OPTION-'
built-in-type: |--+-+---SMALLINT---+----------------------------------------------------------------------------------------------+--| | +-+-INTEGER-+--+ | | | '-INT-----' | | | '---BIGINT-----' | | .-(5,0)----------------------------. | +-+-+-DECIMAL-+-+--+----------------------------------+---------------------------------------------------------+ | | '-DEC-----' | '-(--+------------------------+--)-' | | '-NUMERIC-----' '-integer--+-----------+-' | | '-, integer-' | | .-(53)----------. | +-+-FLOAT--+---------------+-+----------------------------------------------------------------------------------+ | | '-(--integer--)-' | | | +-REAL---------------------+ | | | .-PRECISION-. | | | '-DOUBLE--+-----------+----' | | .-(1)---------------. | +-+-+-+-CHARACTER-+--+-------------------+--------------+--+----------------+---------------------------------+-+ | | | '-CHAR------' '-(--+---------+--)-' | +-FOR BIT DATA---+ | | | | | '-integer-' | +-FOR SBCS DATA--+ | | | | '---+-+-CHARACTER-+--VARYING-+--(--+---------+--)---' +-FOR MIXED DATA-+ | | | | | '-CHAR------' | '-integer-' '-CCSID--integer-' | | | | '-VARCHAR----------------' | | | | .-(1M)---------------------. | | | '-----+-+-CHARACTER-+--LARGE OBJECT-+------+--------------------------+--+----------------+--+------------+-' | | | '-CHAR------' | '-(--+---------+--+---+--)-' +-FOR SBCS DATA--+ '-AS LOCATOR-' | | '-CLOB------------------------' '-integer-' +-K-+ +-FOR MIXED DATA-+ | | +-M-+ '-CCSID--integer-' | | '-G-' | | .-(1)---------------. | +-+-+---GRAPHIC----+-------------------+---------+--+----------------+-----------+------------------------------+ | | | '-(--+---------+--)-' | '-CCSID--integer-' | | | | | '-integer-' | | | | | '---+-VARGRAPHIC------+--(--+---------+--)---' | | | | '-GRAPHIC VARYING-' '-integer-' | | | | .-(1M)---------------------. | | | '---DBCLOB----+--------------------------+--+----------------+--+------------+-' | | '-(--+---------+--+---+--)-' '-CCSID--integer-' '-AS LOCATOR-' | | '-integer-' +-K-+ | | +-M-+ | | '-G-' | | .-(1)---------------. | +-+-+-BINARY--+-------------------+---------+---------------------------------+---------------------------------+ | | | '-(--+---------+--)-' | | | | | | '-integer-' | | | | | '-+-BINARY VARYING-+--(--+---------+--)-' | | | | '-VARBINARY------' '-integer-' | | | | .-(1M)---------------------. | | | '---+-BLOB----------------+----+--------------------------+--+------------+-' | | '-BINARY LARGE OBJECT-' '-(--+---------+--+---+--)-' '-AS LOCATOR-' | | '-integer-' +-K-+ | | +-M-+ | | '-G-' | +-+---DATE-----------------+------------------------------------------------------------------------------------+ | | .-(--0--)-. | | | +-TIME--+---------+------+ | | | .-(--6--)-. | | | '-TIMESTAMP--+---------+-' | | .-(200)-------------. | +---DATALINK--+-------------------+--+----------------+---------------------------------------------------------+ | '-(--+---------+--)-' '-CCSID--integer-' | | '-integer-' | '---ROWID-------------------------------------------------------------------------------------------------------'
If you do not use ALL, you must use one or more of the keywords listed below. Each keyword grants the privilege described.
If function-name () is specified, the function identified must have zero parameters.
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:
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.
If procedure-name () is specified, the procedure identified must have zero parameters.
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:
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 PROCEDURE statement.
If WITH GRANT OPTION is omitted, the specified authorization-names cannot grant privileges on the functions or procedures specified in the ON clause to another user unless they have received that authority from some other source (for example, from a grant of the system authority *OBJMGT).
Corresponding System Authorities: Privileges granted to either an SQL or external function or procedure are granted to its associated program (*PGM) or service program (*SRVPGM) object. Privileges granted to a Java external function or procedure are granted to the associated class file or jar file. If the associated program, service program, class file, or jar file is not found when the grant is executed, an error is returned.
GRANT and REVOKE statements assign and remove system authorities for SQL objects. The following table describes the system authorities that correspond to the SQL privileges:
SQL Privilege | Corresponding System Authorities when Granting to or Revoking from a Function or Procedure |
---|---|
ALL (Grant or revoke of ALL grants or revokes only those privileges the authorization ID of the statement has) |
*OBJALTER *OBJOPR *EXECUTE *OBJMGT (Revoke only) |
ALTER | *OBJALTER |
EXECUTE |
*EXECUTE *OBJOPR |
WITH GRANT OPTION | *OBJMGT |
SQL Privilege | Corresponding Data Authorities when Granting to or Revoking from a Java Function or Procedure | Corresponding Object Authorities when Granting to or Revoking from a Java Function or Procedure |
---|---|---|
ALL (Grant or revoke of ALL grants or revokes only those privileges the authorization ID of the statement has) | *RWX |
*OBJEXIST *OBJALTER *OBJMGT (Revoke only) |
ALTER | *R | *OBJALTER |
EXECUTE | *RX |
*EXECUTE |
WITH GRANT OPTION | *RWX | *OBJMGT |
Corresponding System Authorities When Checking Privileges to a Function or Procedure: The following table describes the system authorities that correspond to the SQL privileges when checking privileges to a function or procedure. The left column lists the SQL privilege. The right column lists the equivalent system authorities.
SQL Privilege | Corresponding System Authorities |
---|---|
ALTER | *OBJALTER |
EXECUTE |
*EXECUTE and *OBJOPR |
SQL Privilege | Corresponding Data Authorities when Checking Privileges to a Java Function or Procedure | Corresponding Object Authorities when Checking Privileges to a Java Function or Procedure |
---|---|---|
ALTER | *R | *OBJALTER |
EXECUTE | *RX |
*EXECUTE |
Syntax alternatives: The following keywords are synonyms supported for compatibility to prior releases. These keywords are non-standard and should not be used:
Grant the EXECUTE privilege on procedure PROCA to PUBLIC.
GRANT EXECUTE ON PROCEDURE PROCA TO PUBLIC