Create ESQL to customize the behavior of a Compute, Database, or Filter node within an ESQL file.
Before you start
To complete this task, you must have completed the following task:
Within the ESQL file, create a module that is associated with a node in your message flow. A module can be associated with only one node of a particular type (Compute, Database, or Filter). Within the module you can create and use functions and procedures as well as the supplied statements and functions. You can also create local constants and variables.
If you have created constants, functions, or procedures at the broker schema level, you can also refer to these within the module. You can define routines at a level at which many different modules can use them, which can save you development time and maintenance effort.
To create ESQL for a node:
(If you have already created the default file and you click Open ESQL, the file is opened in the editor view and a new module is created and highlighted.)
A skeleton module is created for this node at the end of the ESQL file. Its exact content depends on the type of node.The following module is created for a Compute node:
CREATE COMPUTE MODULE <module_name> CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN -- CALL CopyMessageHeaders(); -- CALL CopyEntireMessage(); RETURN TRUE; END; CREATE PROCEDURE CopyMessageHeaders() BEGIN DECLARE I INTEGER 1; DECLARE J INTEGER CARDINALITY(InputRoot.*[]); WHILE I < J DO SET OutputRoot.*[I] = InputRoot.*[I]; SET I = I + 1; END WHILE; END; CREATE PROCEDURE CopyEntireMessage() BEGIN SET OutputRoot = InputRoot; END; END MODULE;
The module name is determined by the value that you have set for the corresponding node property. The default is <message_flow_name>_<node_type>. The Main function contains calls to two procedures, described below, that are declared within the Compute node module following the function Main. These calls are commented out. If you want to include the function that they provide, uncomment these lines and place them at the appropriate point in the ESQL that you create for Main.
If you are migrating from Version 2.1, this procedure is equivalent to the code generated when you select the Copy message headers button on the Compute node properties dialog.
If you are migrating from Version 2.1, this procedure is equivalent to the code generated when you select the Copy entire message button on the Compute node properties dialog.
If you create an ESQL module for a Database node, the following module is created:
CREATE DATABASE MODULE <module_name> CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN RETURN TRUE; END; END MODULE;
For a Filter node, the module is identical to that created for the Database node except for the first line, which reads:
CREATE FILTER MODULE <module_name>
You must add most of the ESQL within the Main function, that is after the BEGIN statement, and before RETURN TRUE. You can add DECLARE statements within the module that are not within the Main function. To add a new line into the file, press Enter.
To help you to code valid ESQL, the editor displays a list of valid statements and functions at the point of the cursor. To invoke this assistance, click
. On some systems, you might also be able to use the key combination Ctrl+Space. Scroll through the list displayed to find and highlight the one that you want, and press Enter. The appropriate code is inserted into your module, and the list disappears.Content assistance is provided in the following areas:
Content assistance works only if the ESQL can be parsed correctly. Errors such as END missing after BEGIN, and other unterminated block statements, cause parser failures and no content assistance is provided. Try content assistance in other areas around the statement where it does not work to narrow down the point of error. Alternatively, save the ESQL file; saving the file causes validation and all syntax errors are written to the Tasks view. Refer to the errors reported to understand and correct the ESQL syntax. If you use content assistance to generate most statements (such as block statements), these are correctly entered and there is less opportunity for error.
If you prefer, you can open the ESQL file directly and create the module within that file using the editor. To do this:
Whichever method you use to open the ESQL file, be aware that the editor provides functions to help you to code ESQL. This section refers to content assistance but there are further functions available in the editor. For information about these functions, see ESQL editor.
Related concepts
Message flows
Broker schema
ESQL modules
Related tasks
Developing message flow applications
Modifying ESQL for a node
Changing ESQL editor settings
Related reference
Built-in nodes
ESQL
ESQL editor
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
ak09033_ |