Posted: Thu Apr 17, 2014 10:38 am Post subject: Procedure ends prior to reaching the End statement
Newbie
Joined: 25 Mar 2014 Posts: 5
I’m new to both MQ and ESQL.
In my esql compute node I am attempting to make a call to com.bdc.cache.GetTheSettingFromCache(). The com.bdc.cache.GetTheSettingFromCache() returns back to the esql compute node prior to executing all the logic between the Begin and End statements. Can someone provide any suggestions on how to resolve this issue?
Here is a simplified version of my esql compute node which is calling another procedure in a different esql file.
Code:
CREATE COMPUTE MODULE Compute1
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyEntireMessage();
DECLARE mapFrom REFERENCE TO Environment.OriginalMessage.XMLNSC.Order;
DECLARE mapTo REFERENCE TO OutputRoot.XMLNSC.DFSWebservice;
CALL DoMap(mapFrom, mapTo);
SET OutputLocalEnvironment = InputLocalEnvironment;
RETURN TRUE;
END;
-- Perform the more complex mapping bits not handled in the node map!
CREATE PROCEDURE DoMap (IN mapFrom REFERENCE, IN mapTo REFERENCE )
BEGIN
DECLARE localMapFrom REFERENCE TO mapFrom; -- Order
DECLARE localMapTo REFERENCE TO mapTo; -- DeluxeFsWebService
SET localMapTo.(XMLNSC.Attribute)NumberOfBoxes = 1;
SET localMapTo.(XMLNSC.Attribute)Quantity = 50;
SET localMapTo.(XMLNSC.Attribute)Desgin = 'VP5';
SET localMapTo.(XMLNSC.Attribute)Style = 'WAL';
MOVE localMapTo TO mapTo; -- DeluxeFsWebService
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
CREATE PROCEDURE GetCheckOrderPackage ( IN P1 INT )
LANGUAGE DATABASE
DYNAMIC RESULT SETS 1
EXTERNAL NAME "dbo.usp_GetCheckOrderPackage";
CREATE PROCEDURE GetCheckOrderShipMethod ( IN P1 INT )
LANGUAGE DATABASE
DYNAMIC RESULT SETS 1
EXTERNAL NAME "dbo.usp_GetCheckOrderShipMethod";
CREATE PROCEDURE FetchAll()
BEGIN
BEGIN ATOMIC
CALL GetCheckOrderPackage(NULL,luCheckOrderPackage.top[]);
CALL GetCheckOrderShipMethod(NULL,luCheckOrderShipMethod.top[]);
END;
END;
CREATE PROCEDURE GetTheSettingFromCache (IN whichSetting REFERENCE, IN settingValue REFERENCE)
BEGIN
-- luCheckOrderPackage is null when the first call is made so FetchAll will execute
IF luCheckOrderPackage IS NULL THEN
CALL FetchAll();
END IF;
-- Procedure ends after the FetchAll call and never reaches this point
CALL LookupPackage(whichSetting.Order.PackageId);
END;
CREATE PROCEDURE LookupPackage(IN packageId CHARACTER)
BEGIN
DECLARE mapFrom REFERENCE TO luCheckOrderPackage.Top[];
WHILE mapFrom IS NOT NULL DO
IF mapFrom.CheckOrderPackageId = packageId THEN
declare i int;
END IF;
MOVE mapFrom LASTCHILD;
END WHILE;
You're passing the reference to luCheckOrderPackage.top[] but the top element has never been defined to the row.
Do something like in procedure FETCH ALL
Code:
DECLARE lupackage REFERENCE TO luCheckOrderPackage.top;
IF NOT LASTMOVE(lupackage) THEN
CREATE LASTCHILD OF luCheckOrderPackage NAME 'top';
MOVE lupackage TO luCheckOrderPackage.top;
END IF;
DECLARE lushipmethod REFERENCE TO luCheckOrderShipMethod.top;
IF NOT LASTMOVE(lushipmethod) THEN
CREATE LASTCHILD OF luCheckOrderShipMethod NAME 'top';
MOVE lushipmethod TO luCheckOrderShipMethod.top;
END IF;
This construct allows you to create the top element only if absent (1st time)...
You can then substitute in the DB call the reference you created.
The problem arises because of the call to the dbprocedure.
Normal call would have been
SET <rowname>.top[] = SELECT ....
This construct will create the top element if absent...
Remember ALWAYS check if your reference is valid with LASTMOVE(reference)
And the reason for this is because you have to pass a reference to the DB call and cannot pass a ROW...
Thanks Dave and Dominic... _________________ MQ & Broker admin
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum