|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Looping through the MRM |
« View previous topic :: View next topic » |
Author |
Message
|
Segs |
Posted: Thu Oct 18, 2001 7:16 am Post subject: |
|
|
Voyager
Joined: 04 Oct 2001 Posts: 78 Location: Zurich Financial Services
|
I need to loop round all the data set up in the MRM to check for NULLS prior to passing the message to the output queue. If a NULL is encountered in the MRM is blows up. |
|
Back to top |
|
 |
Outdesign |
Posted: Thu Oct 18, 2001 8:28 am Post subject: |
|
|
Apprentice
Joined: 16 Sep 2001 Posts: 38 Location: Hampshire, UK
|
Could you be more specific here ?
A MRM output message does require all fields to be set.
For example, you input message has 5 fields and your output message has 10 fields, you have to assign a default value to the remaining 5 fields. |
|
Back to top |
|
 |
Segs |
Posted: Thu Oct 18, 2001 8:40 am Post subject: |
|
|
Voyager
Joined: 04 Oct 2001 Posts: 78 Location: Zurich Financial Services
|
The problem is caused because the XML passed in may not contain a specific tag. For example if the following is passed:
or
You can use the following statement to correct it:
SET "OutputRoot"."MRM"."CLIENTID" = COALESCE(InputRoot.XML.clientid,'');
but if the tag is missing all together the above statement doesn't work and a NULL is put into the MRM which causes the error. So the question I'm really asking is how to deal with missing tags when populating the MRM.
Does that make more (if any sense)?
|
|
Back to top |
|
 |
Outdesign |
Posted: Fri Oct 19, 2001 4:58 am Post subject: |
|
|
Apprentice
Joined: 16 Sep 2001 Posts: 38 Location: Hampshire, UK
|
Segs, you need to select the disable HTML option so that we can see your XML message
The COALESCE function returns the first argument that is not null.
In your example I suspect what is happening is that when the element referenced
in the path is missing, you are assigning null by assigning '' (two single quotes
without a space inbetween).
Depending on the datatype of the output field you probably want to assign
a more appropriate default value, like space for character, zero for integer etc.
For example ...
-- assign a default space value for characters
SET OutputRoot.XML.OutMsg.Char1 = COALESCE(InputBody.InMsg.Char1, ' ');
-- assign a default zero value for integers
SET OutputRoot.XML.OutMsg.Int1 = COALESCE(InputBody.InMsg.Int1, 0);
Which is equivalent to ...
IF InputBody.InMsg.Char1 IS NULL THEN
SET OutputRoot.XML.OutMsg.Char1 = ' ';
ELSE
SET OutputRoot.XML.OutMsg.Char1 = InputBody.InMsg.Char1;
END IF;
IF InputBody.InMsg.Int1 IS NULL THEN
SET OutputRoot.XML.OutMsg.Int1 = 0;
ELSE
SET OutputRoot.XML.OutMsg.Int1 = InputBody.InMsg.Int1;
END IF;
I have not tested this, but think this may be the case ...
|
|
Back to top |
|
 |
Miriam Kaestner |
Posted: Fri Oct 19, 2001 5:39 am Post subject: |
|
|
Centurion
Joined: 26 Jun 2001 Posts: 103 Location: IBM IT Education Services, Germany
|
COALESCE should work to insert default values.
I have a working flow with this compute node:
DECLARE I INTEGER;
SET I = 1;
WHILE I < CARDINALITY(InputRoot.*[]) DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
SET OutputRoot.Properties.MessageSet = 'DI8MVP807M001';
SET OutputRoot.Properties.MessageType = 'm_Simple_Msg';
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
set OutputRoot.Properties.MessageFormat = 'CWF';
set "OutputRoot"."MRM"."e_Int" = coalesce(InputBody.Field1,1);
set "OutputRoot"."MRM"."e_Str" = coalesce(InputBody.Field2,'');
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|