Author |
Message
|
omatan234 |
Posted: Mon Jun 12, 2017 11:17 am Post subject: Adding new elements into an existing element with ESQL |
|
|
Newbie
Joined: 12 Jun 2017 Posts: 8
|
I Have this element in XML for exmple:
<Apple>
<age>2</age>
<size>6</size>
</Apple>
and i have a reference to number of elements that i want to insert under the 'size' element in ESQL without loops.
In the end, for reference to elements like:
<shape>round</shape>
<color>red</color>
<origin>fruit<origin>
the final result spouse to be:
<Apple>
<age>2</age>
<size>6</size>
<shape>round</shape>
<color>red</color>
<origin>fruit<origin>
</Apple> |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jun 12, 2017 11:36 am Post subject: Re: Adding new elements into an existing element with ESQL |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
omatan234 wrote: |
i have a reference to number of elements that i want to insert under the 'size' element in ESQL without loops. |
Why would you need a loop? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jun 12, 2017 11:39 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
What requirements would possibly indicate that you should or should not use loops? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
omatan234 |
Posted: Mon Jun 12, 2017 9:49 pm Post subject: |
|
|
Newbie
Joined: 12 Jun 2017 Posts: 8
|
I thought of moving the new elements one by one with a loop (the number of elements is not constant and that's why i said loop) but i want to insert them in a singel command.
Is there any way to do it ? |
|
Back to top |
|
 |
timber |
Posted: Mon Jun 12, 2017 11:51 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
I assume you were hoping for something like a Perl slice, where you can add a list of elements to an array in one statement. ESQL does not have that facility.
I know you don't want to use a loop, but...
Code: |
FOR refSource AS sourceElement.*[] DO
CREATE LASTCHILD OF refDestination FROM refSource
END FOR; |
I don't think that's too bad. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 13, 2017 3:53 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
timber wrote: |
I assume you were hoping for something like a Perl slice, where you can add a list of elements to an array in one statement. ESQL does not have that facility |
I suspect that someone else might suggest a SELECT statement.
But that's complicated and messy and hard to read and debug, so there's no strong reason to use it instead of a loop. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
|