GRANT (Package Privileges)
This form of the GRANT statement grants privileges on a package.
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 each package identified in the statement:
- Every privilege specified in the statement
- The system authority of *OBJMGT on the package
- The system authority *EXECUTE on the library containing the package
- Administrative authority
If WITH GRANT OPTION is specified, the privileges held by the authorization ID of the statement must include at least one of the following:
- Ownership of the package
- Administrative authority
Syntax
.-PRIVILEGES-. >>-GRANT--+-ALL--+------------+-+-------------------------------> | .-,-----------. | | V | | '---+-ALTER---+-+-----' '-EXECUTE-' .-,------------. V | >--ON PACKAGE----package-name-+---------------------------------> .-,----------------------. V | >--TO----+-authorization-name-+-+--+-------------------+------->< '-PUBLIC-------------' '-WITH GRANT OPTION-'
Description
- ALL or ALL PRIVILEGES
- Grants
one or more privileges. The privileges granted are all those grantable
privileges that the authorization ID of the statement has on the specified
packages. Note that granting ALL PRIVILEGES on a package is not the
same as granting the system authority of *ALL.
If you do not use ALL, you must use one or more of the keywords listed below. Each keyword grants the privilege described.
- ALTER
- Grants the privilege to use the COMMENT and LABEL statements.
- EXECUTE
- Grants the privilege to execute statements in a package.
- ON PACKAGE package-name
- Identifies the packages on which you are granting the privilege. The package-name must identify a package that exists at the current server.
- TO
- Indicates to whom the privileges are granted.
- authorization-name,…
- Lists one or more authorization IDs.
- PUBLIC
- Grants the privileges to a set of users (authorization IDs). For more information, see Authorization, privileges and object ownership.
- WITH GRANT OPTION
- Allows the specified authorization-names to
grant privileges on the packages specified in the ON clause to other
users.
If WITH GRANT OPTION is omitted, the specified authorization-names cannot grant privileges on the packages 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).
Notes
Corresponding System Authorities: 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 Package |
---|---|
ALL (Grant or revoke of ALL grants or revokes only those privileges the authorization ID of the statement has) | *OBJALTER |
ALTER | *OBJALTER |
EXECUTE | *EXECUTE |
WITH GRANT OPTION | *OBJMGT |
Corresponding System Authorities When Checking Privileges to a Package: The following table describes the system authorities that correspond to the SQL privileges when checking privileges to a package. The left column lists the SQL privilege. The right column lists the equivalent system authorities.
SQL Privilege | Corresponding System Authorities When Checking Privileges to a Package |
---|---|
ALTER | *OBJALTER |
EXECUTE | *EXECUTE and *OBJOPR |
Syntax alternatives: The following keywords are synonyms supported for compatibility to prior releases. These keywords are non-standard and should not be used:
- The keyword RUN can be used as a synonym for EXECUTE.
- The keyword PROGRAM can be used as a synonym for PACKAGE.
Example
Grant the EXECUTE privilege on package PKGA to PUBLIC.
GRANT EXECUTE
ON PACKAGE PKGA
TO PUBLIC