Creating and calling your own user-defined ESQL routine

For complex mappings, it is sometimes better to write an ESQL function that performs the work, then call the function from the Message Mapping editor. This topic describes a scenario where one of the output fields will be formed from a concatenation of input fields with additional text.

The message model used in this example is:
simple			(message)
	int			(xsd:int)
	str			(xsd:str)
The ESQL function code used in this example is:
CREATE FUNCTION concatValues(IN val INTEGER, IN str CHAR) RETURNS CHAR
	BEGIN
		return str || ' plus int val ' || CAST(val AS CHAR);
	END;
  1. Switch to the Broker Application Development perspective.
  2. Right-click the Mapping node and click Open Map.
  3. Accept the default Project and Name and click Next.
  4. Accept the default usage and click Next.
  5. Clear the Based on records in a database check box and click Next.
  6. Select the source message simple and the target message simple, and click Finish.
  7. In the Connection pane, open the source and target trees by clicking on the addition (+) symbols.
  8. Open the simple trees on both sides in the same way.
  9. Select int in the Source pane and drag it onto int in the Target pane. A line joins them to represent the mapping.
  10. Right-click the message flow project that contains the message flow and the message map, and click New > Message Flow ESQL File.
  11. Ensure that the name is the same as the name of the message flow, and click Finish.
  12. Open the new ESQL file (for example, flowname.esql) and enter the example ESQL function code that is shown earlier in this topic.
  13. Save the ESQL file.
  14. In the Message Mapping editor Spreadsheet pane, select the Value column for the str item.
  15. In the Edit pane, enter the function call. For example:
    esql:concatValues($source/simple/int, $source/simple/str)
  16. Save the mapping file by clicking File > Save.
Related concepts
Message Mapping editor
Message flows, ESQL, and mappings
Related tasks
Developing ESQL
Related reference
Message Mapping editor Spreadsheet pane
Message Mapping editor Edit pane
CREATE FUNCTION statement
Mapping node
Broker Application Development perspective