Creating objects in modules
Creating objects in modules is a task that you would perform after you have created a module when you have identified a set of routines, data types, and variables (perhaps in support of a single business case) that you would like to define together within a common namespace for easier management and deployment.
Before you begin
- Review the ALTER MODULE statement documentation.
- Ensure that you have the privileges required to execute the ALTER MODULE statement.
About this task
This task is done by executing the ALTER module statement. The ALTER module statement allows objects to be added as published objects or as unpublished objects. Published objects can be referenced from outside of the module, while unpublished objects can be referenced only by other objects in the same module.
Within modules, a procedure or function can be initially defined without a routine-body. These are called prototypes. Prototypes can only be created for published procedures or functions. The routine-body for a published routine prototype can be added later using the same routine signature.
Restrictions
Procedure
Results
Example
ALTER MODULE inventory
PUBLISH PROCEDURE p(IN c1 INT, IN c2 INT, IN c3 CHAR) @
ALTER MODULE inventory
PUBLISH PROCEDURE q(IN c1 INT, IN c2 VARCHAR(8))@
ALTER MODULE inventory
ADD PROCEDURE p(IN c1 INT, IN c2 INT, IN c3 CHAR)
LANGUAGE SQL
BEGIN
IF c1 > 10 THEN
CALL q(1, 'hello')
ELSE IF c2 > 5 THEN
SET c3 = CHAR(c2);
END IF;
END@
ALTER MODULE inventory
ADD PROCEDURE r(c1 INT, c2 INT, c3 CHAR)
LANGUAGE SQL
BEGIN
CALL q(1, 'hello');
END@