|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Parent node created when setting child to NULL |
« View previous topic :: View next topic » |
Author |
Message
|
fazz |
Posted: Mon Nov 16, 2009 6:42 am Post subject: Parent node created when setting child to NULL |
|
|
 Centurion
Joined: 20 Feb 2004 Posts: 144 Location: England
|
Hello,
I am having problems with MB creating unwanted nodes in a tree.
Consider the following statement:
Code: |
SET refOutput.MRM.nsDeal:Party[index1].nsDeal:Brokers.nsDeal:Broker[index2].nsDeal:BrokerId[index3] = NULLIF(refInput.XMLNSC.BosActions.BosAction.BUY_BROKER_TEXT,''); |
index1 = 1
index2 = 2
index3 = 1
refInput.XMLNSC.BosActions.BosAction.BUY_BROKER_TEXT = ''
At the moment this command is run, 'Party[1]' does exist, 'Broker[2]' does not exist neither does BrokerId[1].
As you can see from the trace, it is assigning NULL to BrokerId[1] which is what I want, however, it also leaves behind an empty Broker[2], which I do not want.
Code: |
Executing statement ''SET refOutput.MRM.nsDeal:Party[index1].nsDeal:Brokers.nsDeal:Broker[index2].nsDeal:BrokerId[index3] = NULLIF(refInput.XMLNSC.BosActions.BosAction.BUY_APP_BROKER2_TEXT, '');'' at ('com.icap.esb.system.transform.bosserver.lib.CreateCommonTypes', '1125.8').
2009-11-16 13:34:51.793125 3852 UserTrace BIP2539I: Node 'com.icap.esb.system.adapter.bosserver.ADP_BOSServerRQST.Transform BOS to Canonical.SPOT_TO_CANON_SF.CREATE': Evaluating expression ''refInput.XMLNSC.BosActions.BosAction.BUY_APP_BROKER2_TEXT'' at ('com.icap.esb.system.transform.bosserver.lib.CreateCommonTypes', '1126.17'). This resolved to ''refInput.XMLNSC.BosActions.BosAction.BUY_APP_BROKER2_TEXT''. The result was ''''''.
2009-11-16 13:34:51.793136 3852 UserTrace BIP2539I: Node 'com.icap.esb.system.adapter.bosserver.ADP_BOSServerRQST.Transform BOS to Canonical.SPOT_TO_CANON_SF.CREATE': Evaluating expression ''NULLIF(refInput.XMLNSC.BosActions.BosAction.BUY_APP_BROKER2_TEXT, '')'' at ('com.icap.esb.system.transform.bosserver.lib.CreateCommonTypes', '1126.10'). This resolved to ''NULLIF('', '')''. The result was ''NULL''.
2009-11-16 13:34:51.793148 3852 UserTrace BIP2539I: Node 'com.icap.esb.system.adapter.bosserver.ADP_BOSServerRQST.Transform BOS to Canonical.SPOT_TO_CANON_SF.CREATE': Evaluating expression ''index1'' at ('com.icap.esb.system.transform.bosserver.lib.CreateCommonTypes', '1125.39'). This resolved to ''index1''. The result was ''1''.
2009-11-16 13:34:51.793155 3852 UserTrace BIP2539I: Node 'com.icap.esb.system.adapter.bosserver.ADP_BOSServerRQST.Transform BOS to Canonical.SPOT_TO_CANON_SF.CREATE': Evaluating expression ''index2'' at ('com.icap.esb.system.transform.bosserver.lib.CreateCommonTypes', '1125.76'). This resolved to ''index2''. The result was ''2''.
2009-11-16 13:34:51.793167 3852 UserTrace BIP2539I: Node 'com.icap.esb.system.adapter.bosserver.ADP_BOSServerRQST.Transform BOS to Canonical.SPOT_TO_CANON_SF.CREATE': Evaluating expression ''index3'' at ('com.icap.esb.system.transform.bosserver.lib.CreateCommonTypes', '1125.100'). This resolved to ''index3''. The result was ''1''.
2009-11-16 13:34:51.793178 3852 UserTrace BIP2567I: Node 'com.icap.esb.system.adapter.bosserver.ADP_BOSServerRQST.Transform BOS to Canonical.SPOT_TO_CANON_SF.CREATE': Assigning NULL to ''refOutput.MRM.nsDeal:Party[index1].nsDeal:Brokers.nsDeal:Broker[index2].nsDeal:BrokerId[index3]'', thus deleting it. |
This is a trace on the output, you can see the empty Broker element at the end.
Code: |
(0x01000000:Name )http://icap.com/backoffice/schema/Deal:Brokers = (
(0x01000000:Name)http://icap.com/backoffice/schema/Deal:Broker = (
(0x03000000:NameValue)http://icap.com/backoffice/schema/Deal:BrokerId = 'last, first' (CHARACTER)
(
(0x03000100:NameValue+):idType = 'local-name' (CHARACTER)
)
(0x03000000:NameValue)http://icap.com/backoffice/schema/Deal:BrokerId = '01' (CHARACTER)
(
(0x03000100:NameValue+):idType = 'local-id' (CHARACTER)
)
(0x03000000:NameValue)http://icap.com/backoffice/schema/Deal:ProfitCentre = '02' (CHARACTER)
(
(0x03000100:NameValue+):idType = 'local-id' (CHARACTER)
)
(0x03000000:NameValue)http://icap.com/backoffice/schema/Deal:ProfitCentre = 'GB' (CHARACTER)
(
(0x03000100:NameValue+):idType = 'local-name' (CHARACTER)
)
(0x03000000:NameValue)http://icap.com/backoffice/schema/Deal:BrokeragePercentage = '100' (CHARACTER)
)
(0x01000000:Name)http://icap.com/backoffice/schema/Deal:Broker = |
Note that the first Broker (index2=1) is expected, the second Broker (index2=2) should not be present.
Any ideas? |
|
Back to top |
|
 |
mgk |
Posted: Mon Nov 16, 2009 6:56 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
SETting an element to NULL in ESQL will delete that element, but it will not delete the parent of that element. Using the SET statement as you are will force creation of all the elements in the path, and then delete the last one as you see. To do what you are trying to do look at using EXISTS before you use SET... _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
fazz |
Posted: Mon Nov 16, 2009 7:05 am Post subject: |
|
|
 Centurion
Joined: 20 Feb 2004 Posts: 144 Location: England
|
Thanks for the prompt response.
I had feared that was the case.
Is there a reason as to why it behaves like this, it seems strange that when setting a field, all other fields will be created even if that last field is not set. |
|
Back to top |
|
 |
mgk |
Posted: Mon Nov 16, 2009 7:16 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
SET has always behaved this way by design. Normally when using SET you want to set an element to a particular value and to be able to do this you want the elements to be created automatically as otherwise you have to create them all manually before the SET can be used which would require more code. You can think of setting an element to NULL to delete the element as a convenience (as you can use DELETE instead).
So in your case you could check that the element exist first (with EXISTS) or use the DELETE statement if your condition is met...
I hope this helps.
Kind Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
fazz |
Posted: Mon Nov 16, 2009 8:57 am Post subject: |
|
|
 Centurion
Joined: 20 Feb 2004 Posts: 144 Location: England
|
Ok thanks, I will add a check to see if the field exists first. |
|
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
|
|
|
|