11.19.1.Syntax

CREATE MODULE
  m_name
{
  [PROCEDURE|FUNCTION] p_name1 (...) { ...};
  [PROCEDURE|FUNCTION] p_name2 (...) { ...};
  ...
  [PROCEDURE|FUNCTION] p_nameN (...) { ...};
}
DROP MODULE m_name;

Example11.15.Procedure Modules

create module
  DB.DBA.MOD
{
  function MOD1 () returns varchar {
    return ('MOD1');
  };

  procedure MOD2 () {
    return concat (MOD1(), 'MOD2');
  };
};

This example creates a module, MOD, with 2 procedures: MOD1 & MOD2. Their fully-qualified names are DB.DBA.MOD.MOD1 and DB.DBA.MOD.MOD2.

Note the call to MOD1 in MOD2 - it is not fully qualified, but it resolves to the module procedure MOD1, instead of any procedure external to the module.


A single part procedure name in a call inside a module is first matched against procedures defined in the module. If the above example were executed by DBA (in the DB qualifier), then the below statements are equivalent:

select DB.DBA.MOD.MOD1()
select DB..MOD.MOD1()

The statement:

select MOD.MOD1()

will result in calling the DB.DBA.MOD.MOD1() only if a function DB.MOD.MOD1 does not exist. If it exists, it will be preferred over DB.DBA.MOD.MOD1 when using this notation.