This form of the GRANT statement grants privileges on a package.
Invocation
This statement can be embedded in an application program or issued through the use of dynamic SQL statements. It is an executable statement that can be dynamically prepared. However, if the bind option DYNAMICRULES BIND applies, the statement cannot be dynamically prepared (SQLSTATE 42509).
Authorization
The privileges held by the authorization ID of the statement must include at least one of the following:
To grant the CONTROL privilege, SYSADM or DBADM authority is required.
Refer to GRANT (Database Authorities), GRANT (Index Privileges), GRANT (Schema Privileges), GRANT (Server Privileges) and GRANT (Table, View, or Nickname Privileges) for other GRANT statements.
Syntax
.-,-------------------. V | >>-GRANT--------+-BIND---------+--+-----------------------------> +-CONTROL------+ | (1) | '-EXECUTE------' (2) >----ON--PACKAGE-------package-name-----------------------------> .-,------------------------------------. V | >----TO----+-+-------+---authorization-name--+--+-------------->< | +-USER--+ | | '-GROUP-' | '-PUBLIC--------------------------'
Notes:
Description
In addition to the BIND privilege, the user must hold the necessary privileges on each table referenced by static DML statements contained in the program. This is necessary because authorization on static DML statements is checked at bind time.
BIND and EXECUTE are automatically granted to an authorization-name that is granted CONTROL privilege.
The list of authorization IDs cannot include the authorization ID of the user issuing the statement (SQLSTATE 42502).
Rules
Examples
Example 1: Grant the EXECUTE privilege on PACKAGE CORPDATA.PKGA to PUBLIC.
GRANT EXECUTE ON PACKAGE CORPDATA.PKGA TO PUBLIC
Example 2: GRANT EXECUTE privilege on package CORPDATA.PKGA to a user named EMPLOYEE. There is neither a group nor a user called EMPLOYEE.
GRANT EXECUTE ON PACKAGE CORPDATA.PKGA TO EMPLOYEE
or
GRANT EXECUTE ON PACKAGE CORPDATA.PKGA TO USER EMPLOYEE