Author |
Message
|
bmccarty |
Posted: Wed May 01, 2002 2:53 pm Post subject: |
|
|
Apprentice
Joined: 18 Dec 2001 Posts: 43
|
Hi,
For every message flow there can be only one input message tree, but can that message be split into multiple messages for output? Specifically I am looking to extract so rows from a database with a compute node and then based on the results, create multpile output messages from the results. Outside of WMQI this is a simple question, but the customer like to house the functionality inside of WMQI because of what they have done thus far without using outside code.
Using WMQI 2.1 CSD02
Thanks for the help!
B |
|
Back to top |
|
 |
kirani |
Posted: Wed May 01, 2002 4:09 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Yes, this is very much possible in WMQI. You can make use of PROPAGATE function in ESQL.
_________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
bmccarty |
Posted: Thu May 02, 2002 2:54 pm Post subject: |
|
|
Apprentice
Joined: 18 Dec 2001 Posts: 43
|
I think that I got it. Here is the ESQL that I used as a sample. It uses the SAMPLE database shipped with DB2 if you want to try it out.
SET OutputRoot = InputRoot;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
DECLARE i INTEGER;
SET i = 1;
SET InputDestinationList.XML.TempData."DeptName"[] = (SELECT ITEM T.DEPTNAME FROM Database.DB2ADMIN.DEPARTMENT AS T);
WHILE i <= CARDINALITY(InputDestinationList.XML.TempData."DeptName"[]) DO
SET OutputRoot = InputRoot;
SET OutputRoot.XML = NULL;
SET OutputRoot.XML.Department."DeptName" = InputDestinationList.XML.TempData."DeptName"[i];
PROPAGATE;
SET i = i+1;
END WHILE;
RETURN FALSE;
These seems to work fine, but if you have any suggestions for enhancement, please pass them along.
Thanks for the help.
B |
|
Back to top |
|
 |
kirani |
Posted: Thu May 02, 2002 3:30 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
I would like to suggest a very small change here. This may not affect you right now, but when you are dealing with large messages it will affect your performance.
Don't use CARDINALITY in a loop. Instead use it like this ...
...
DECLARE CNT INTEGER;
SET CNT = CARDINALITY(InputDestinationList.XML.TempData."DeptName"[]);
WHILE (i <= CNT) DO
....
END WHILE;
RETURN FALSE;
_________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
bmccarty |
Posted: Fri May 03, 2002 7:25 am Post subject: |
|
|
Apprentice
Joined: 18 Dec 2001 Posts: 43
|
|
Back to top |
|
 |
CodeCraft |
Posted: Sun May 05, 2002 9:18 am Post subject: |
|
|
Disciple
Joined: 05 Sep 2001 Posts: 195
|
And, the reason it affects performance is, everytime you use it, the function goes off and does a count of whatever it is you asked for. Since the tree may be different in every iteration, it's poor for performance, but can also give unpredictable (if you're not thinking) results. |
|
Back to top |
|
 |
CodeCraft |
Posted: Mon May 06, 2002 1:28 am Post subject: |
|
|
Disciple
Joined: 05 Sep 2001 Posts: 195
|
P.S. This can also be done in 2.0x, but is more tricky! |
|
Back to top |
|
 |
|