ESQL modules overview

A module is a sequence of declarations that define variables and their initialization, and a sequence of subroutine (function and procedure) declarations that define a specific behavior for a message flow node.

A module must begin with the CREATE node_type MODULE statement and end with an END MODULE statement. The node_type must be one of COMPUTE, DATABASE, DATABASEEVENT, or FILTER. For DatabaseInput nodes, the required node_type is DATABASEEVENT. For Compute, Database, and Filter nodes the required node_type is the same as the node. For example, you must use the COMPUTE node_type in ESQL modules for Compute nodes. For Compute, Database and Filter nodes, the entry point of the ESQL code is the function named MAIN, which has MODULE scope. ESQL modules for DatabaseInput nodes do not contain the MAIN function, but contain three procedures named READEVENTS, BUILDMESSAGE, and ENDEVENT. For more information about these three procedures, see Configuring a DatabaseInput node.

Each module is identified by a name which follows CREATE node_type MODULE. The name might be created for you with a default value, which you can modify, or you can create it yourself. The name is handled in a non-case-sensitive way (that is, use of the name with any combination of uppercase and lowercase letters matches the declaration). This is in contrast to the names that you declare for schemas, constants, variables, and labels, which are handled in a case-sensitive way, and which you must specify exactly as you declared them.

You must create the code for a module in an ESQL file which has a suffix of .esql. You must create this file in the same broker schema as the node that references it. There must be one module of the correct type for each corresponding node, and it is specific to that node and cannot be used by any other node.

When you create an ESQL file (or complete a task that creates one), you indicate the integration project and broker schema with which the file is associated and specify a name for the file.

Within the ESQL file, the name of each module is determined by the value of the corresponding property of the message flow node. For example, the property ESQL Module for the Compute node specifies the name of the module in the ESQL file for that node. The default value for this property is the name of the node. You can specify a different name, but you must ensure that the value of the property and the name of the module that provides the required function are the same.

For Compute, Database, and Filter nodes, the module must contain the function MAIN, which is the entry point for the module. This function is included automatically if the module is created for you. Within MAIN, you can code ESQL to configure the behavior of the node. If you include ESQL within the module that declares variables, constants, functions, and procedures, these are of local scope only and can be used within this single module.

For DatabaseInput nodes, the module must contain the three procedures READEVENTS, BUILDMESSAGE, and ENDEVENT. These procedures are included automatically, together with comments to describe the procedure, if the module is created for you. Within the three procedures, you can code ESQL to configure the behavior of the node, see Configuring a DatabaseInput node. If you include ESQL within the module that declares variables, constants, functions, and procedures, these are of local scope only and can be used within this single module.

If you want to reuse ESQL constants, functions, or procedures, you must declare them at broker schema level. You can then refer to these constants, functions or procedures from any resource within that broker schema, in the same or another project. If you want to use this technique, either fully qualify the procedure, or include a PATH statement that sets the qualifier. The PATH statement must be coded in the same ESQL file, but not within any MODULE.