In the Error Handler Message Flows project, double-click the Error_Handler.esql file to open it in the ESQL editor. Copy and paste the following ESQL code modules to the ESQL file, then save the file.
For more information, see Developing ESQL.
CREATE FILTER MODULE Error_Handler_Filter
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
IF Root.MQMD.BackoutCount='0' THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;
END MODULE;
CREATE DATABASE MODULE Error_Handler_Database
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE Error INTEGER;
DECLARE Text CHARACTER;
DECLARE Place INTEGER;
DECLARE LastPlace INTEGER;
DECLARE NodeName CHARACTER;
DECLARE Label CHARACTER;
DECLARE FlowName CHARACTER;
-- Set the start point
DECLARE start REFERENCE TO ExceptionList.*[1];
WHILE start.Number IS NOT NULL DO
SET Error = start.Number;
IF Error = 3001 THEN
SET Text = SUBSTRING(start.Insert.Text FROM 1 FOR 250);
ELSE
SET Text = SUBSTRING(start.Text FROM 1 FOR 250);
END IF;
SET Label = start.Label;
SET Place = POSITION('.' IN Label);
SET LastPlace = Place;
WHILE Place <>0 DO
SET Label=SUBSTRING(Label FROM (Place+1));
SET Place=POSITION('.' IN Label);
SET LastPlace = LastPlace + Place;
END WHILE;
SET Label=start.Label;
SET FlowName=SUBSTRING(Label FROM 1 FOR (LastPlace-1));
SET NodeName=SUBSTRING(Label FROM (LastPlace+1));
-- Move start to the last child of the field to which it currently points
MOVE start LASTCHILD;
END WHILE;
INSERT INTO Database.ERRORS(MSGID,TEXT,ERRORNUM, ERRORDATE,MSGDATA,FLOWNAME,NODENAME)
VALUES(CAST(Root.MQMD.MsgId AS BLOB),Text,Error,CURRENT_TIMESTAMP,BITSTREAM(Root),
FlowName,NodeName);
RETURN TRUE;
END;
END MODULE