Implementing routine-bodies for defined routine prototype in a module is a task that you can do after defining one or more routine prototypes.
Module SQL procedures are allowed to be declared as prototypes first. SQL procedure prototypes allow you to define the procedure and its parameters without, at the same time, having to specify the logic of the routine-body.
Defining routine prototypes before completing the routine implementation is useful and allows you to not worry about the order of creation of routines that cross-reference other routines. For example, without using prototypes if you had 3 routines named, A, B, and C and programmatically you wanted A to call B, and have B call C, then the routines would had to be created in the following order: C, B, and then A. If routine prototypes are created first, this allows you to implement the routines in any order, reference the other routines by name and implement them later.
Routines without routine-bodies cannot be invoked. Implementing the routine-bodies for routines that have been defined as prototypes is a prerequisite to successfully invoking the routine.
Restrictions
For restrictions on modules see:Restrictions on modulesCREATE MODULE moo@
ALTER MODULE moo PUBLISH PROCEDURE prot
(IN a INT, IN b BIGINT, IN c VARCHAR(20))
LANGUAGE SQL@
ALTER MODULE moo ADD PROCEDURE prot
(IN a INT, IN b BIGINT, IN c VARCHAR(20))
BEGIN
DECLARE stmt VARCHAR(1000);
DECLARE c1 CURSOR WITH RETURN FOR sl;
SET stmt = 'SELECT 1 FROM (values(1))';
PREPARE sl FROM stmt;
OPEN c1;
END@
ALTER MODULE moo PUBLISH FUNCTION fprot (r1 INT)
RETURNS int@
ALTER MODULE moo ADD FUNCTION fprot (r1 INT)
RETURNS int
BEGIN
RETURN r1-1;
END
@