IBM ESQL dynamically access to fields

4.2k views Asked by At

i need to access to a field using variable,

  1. i have the enviroment variable containing the path of the field i need to modify es. SET Environment.Variabili.Mappings.mapping[1].xpath='trades.trade[1].id';

  2. i want to modify the value of this field usinng the enviroment variable es.SET OutputRoot.XML.MxML.{Environment.Variabili.Mappings.mapping[1].xpath}='test';

But it does not modify the field but it create an other field like this:

<MxML>
  ...
  ...
  ...
  <trades.trade[1].id>test</trades.trade[1].id>
<MxML>

Is it possible to dynamically acces to the XML field?

Ty. Regards.

1

There are 1 answers

0
kimbert On BEST ANSWER

You are accidentally using the XML domain. Your statement should be SET OutputRoot.XMLNSC.MxML...

Your ESQL SET statement is behaving according to the specification. It has created a new tag with the name taken from the value of Environment.Variabili.Mappings.mapping[1].xpath

If you want to dynamically create subfields within the output tree then you will need to - write some ESQL to tokenize the value of Environment.Variabili.Mappings.mapping[1].xpath - use the CREATE statement to create each field in the output tree.

Before you go ahead and write that code, you may want to consider a change of design. It would be easier to create the tree structure in the Environment tree and just copy it into OutputRoot.XMLNSC.