|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Pls Help me out!!! |
« View previous topic :: View next topic » |
Author |
Message
|
MQTORTOISE |
Posted: Thu Jan 16, 2003 11:57 am Post subject: Pls Help me out!!! |
|
|
 Novice
Joined: 24 Dec 2002 Posts: 15
|
Hi ,Pls can any body suggest me the code for following input..
<Table>
<element1>Hi</element1>
<element2>Hello</element2>
</Table>
I do get elements in a Table ,i may get 2 or 1 elements.So depending on the input element i need to generate the output.I wrote code for element1 is null then do something orelse do something,but i cant generate correct output.
My output should be like
<select>Hi,Hello</select>if both elements exist in input
or else
<select>Hi</select>if element1 exist in input
Thanks in Adv,
MQTortoise..  |
|
Back to top |
|
 |
fschofer |
Posted: Fri Jan 17, 2003 12:26 am Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
Hello MQTORTOISE,
here is my untested solution for your problem and i do not know if it's
the best one. But i think it will work.
DECLARE second_string CHAR;
SET second_string = ',' || COALESCE(InputRoot.XML.Table.element2, '');
IF ( LENGTH(second_string > 1) ) THEN
SET OutputRoot.XML.select = InputRoot.XML.Table.element1 || second_string;
ELSE
SET OutputRoot.XML.select = InputRoot.XML.Table.element1
END IF;
If you do not know the names of your elements or
element 2 can be the only one in your input you can use
*[1] instead of element1 and *[2] instead of element1 |
|
Back to top |
|
 |
MQTORTOISE |
Posted: Fri Jan 17, 2003 6:16 am Post subject: |
|
|
 Novice
Joined: 24 Dec 2002 Posts: 15
|
Thanks Schofer,I have used COALESCE function ,it seems the function is not working in my code.Anyhow thanks for your code...
Thanks again,
MQTortoise... |
|
Back to top |
|
 |
yaakovd |
Posted: Mon Jan 20, 2003 9:53 am Post subject: |
|
|
Partisan
Joined: 20 Jan 2003 Posts: 319 Location: Israel
|
Hi
You must check if both of elements are exist in input, otherwise concatenation will faled.
IF(InputRoot.XML.Table.element1 IS NULL OR InputRoot.XML.Table.element1 IS NULL)THEN
SET OutputRoot.XML.select = COALESCE (InputRoot.XML.Table.element1 , InputRoot.XML.Table.element2);
ELSE
SET OutputRoot.XML.select = InputRoot.XML.Table.element1 || ',' || InputRoot.XML.Table.element2;
END IF;
If COALESCE function is not working (it is unbelievable) use following:
IF(InputRoot.XML.Table.element1 IS NULL)
SET OutputRoot.XML.select = InputRoot.XML.Table.element2;
ELSE IF( InputRoot.XML.Table.element2 IS NULL)THEN
SET OutputRoot.XML.select = InputRoot.XML.Table.element1;
ELSE
SET OutputRoot.XML.select = InputRoot.XML.Table.element1 || ',' || InputRoot.XML.Table.element2;
END IF;
END IF; _________________ Best regards.
Yaakov
SWG, IBM Commerce, Israel |
|
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
|
|
|
|