DB2 10.5 for Linux, UNIX, and Windows

CREATE MODULE statement

The CREATE MODULE statement creates a module at the application server.

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 only if DYNAMICRULES run behavior is in effect for the package (SQLSTATE 42509).

Authorization

The privileges held by the authorization ID of the statement must include at least one of the following authorities:
  • IMPLICIT_SCHEMA authority on the database, if the implicit or explicit schema name of the module does not exist.
  • CREATEIN privilege on the schema, if the schema name of the module refers to an existing schema.
  • DBADM authority
To replace an existing module, the authorization ID of the statement must be the owner of the existing module (SQLSTATE 42501).

Syntax

Read syntax diagramSkip visual syntax diagram
>>-CREATE--+------------+--MODULE--module-name-----------------><
           '-OR REPLACE-'                        

Description

OR REPLACE
Specifies replacing the definition for the module if one exists at the current server. The existing module definition is effectively dropped, including all the objects in the module, before the new definition is replaced in the catalog, with the exception that privileges that were granted on the module are not affected. This option is ignored if a definition for the module does not exist at the current server. This option can be specified only by the owner of the object.
module-name
Names the module. The name, including the implicit or explicit qualifier, must not identify an existing module at the current server. The module name and the schema name must not begin with the characters 'SYS' (SQLSTATE 42939) and use of SESSION is not recommended.

Notes

Example

Create a module named salesModule
   CREATE MODULE salesModule