Author |
Message
|
gecs |
Posted: Thu Sep 03, 2009 11:26 am Post subject: Transform array message |
|
|
 Acolyte
Joined: 14 Nov 2007 Posts: 58
|
Hi everybody, some knows how to get solution below:
Input:
Code: |
Root
- MRM
- Tarjeta1
- Cuenta A
- Cuenta B
- Cuenta C
- Cuenta D
- Tarjeta2
- Cuenta E
- Cuenta F
- Cuenta G
- Tarjeta... (n)
- Cuenta... (m)
- Cuenta... (o)
- Cuenta... (p)
.
.
.
|
Output:
Code: |
Root
- MRM
- Cuentas
- Cuenta A
- Cuenta B
- Cuenta E
- Cuenta G
|
How can I do this without using LOOP, FOR, WHILE, REPEAT sentences.
Is there any solution using SELECT?
Thanks. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 03, 2009 11:29 am Post subject: Re: Transform array message |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
gecs wrote: |
How can I do this without using LOOP, FOR, WHILE, REPEAT sentences.
Is there any solution using SELECT?
|
What's the opposition to loop constructs?
What are the criteria for inclusion in the output? Why are C, D & F excluded? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
gecs |
Posted: Thu Sep 03, 2009 12:58 pm Post subject: Re: Transform array message |
|
|
 Acolyte
Joined: 14 Nov 2007 Posts: 58
|
[quote="Vitor"]
gecs wrote: |
How can I do this without using LOOP, FOR, WHILE, REPEAT sentences.
Is there any solution using SELECT?
|
|
|
Back to top |
|
 |
gecs |
Posted: Thu Sep 03, 2009 1:00 pm Post subject: |
|
|
 Acolyte
Joined: 14 Nov 2007 Posts: 58
|
What's the opposition to loop constructs?
What are the criteria for inclusion in the output? Why are C, D & F excluded?[/quote]
the opposition? anything.
the criteria? it doesn't matter, ouput can contain the other excluded elements...
the out put can be:
Quote: |
Root
- MRM
- Cuentas
- Cuenta A
- Cuenta B
- Cuenta C
- Cuenta D
- Cuenta E
- Cuenta F
- Cuenta G
- Cuenta (m)
- Cuenta (o)
- Cuenta (p)
- ....
- ....
- ....
|
I'm only want to know if is possible get the output without using LOOP sentences... some like this:
Quote: |
SET OutputRoot.MRM.Cuentas.Cuenta[] = SELECT * FROM InputRoot.MRM.Tarjeta.Cuenta[] AS C; |
but this only get the fields "Cuenta" of one(the first) ocurrence of "Tarjeta". How can I do to get the rest in the same output?
thanks... for your time... |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 03, 2009 1:09 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
gecs wrote: |
I'm only want to know if is possible get the output without using LOOP sentences... some like this:
Quote: |
SET OutputRoot.MRM.Cuentas.Cuenta[] = SELECT * FROM InputRoot.MRM.Tarjeta.Cuenta[] AS C; |
but this only get the fields "Cuenta" of one(the first) ocurrence of "Tarjeta". |
Yes, it is, using something like that.
You might well find that, depending on the complexity of the inclusion/exclusion criteria, a loop will be easier to maintain.
I'd doubt there's much performance difference between a SELECT and a properly written loop. I welcome comments on this.
(By "properly written" I explicitly exclude anything including anything like
Code: |
SET OutputRoot.MRM.Cuentas.Cuenta[I] = InputRoot.MRM.Tarjeta.Cuenta[I];
SET I = I + 1;
|
) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Sep 03, 2009 1:27 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Vitor wrote: |
gecs wrote: |
I'm only want to know if is possible get the output without using LOOP sentences... some like this:
Quote: |
SET OutputRoot.MRM.Cuentas.Cuenta[] = SELECT * FROM InputRoot.MRM.Tarjeta.Cuenta[] AS C; |
but this only get the fields "Cuenta" of one(the first) ocurrence of "Tarjeta". |
Yes, it is, using something like that. |
Of course, it would have to be proper ESQL SELECT syntax, which the example shown is not.
Presumably gecs has the correct syntax in the ESQL file that is correctly generating the result mentioned (which is different than the result desired).
Gecs - you can get the result you want by a very simple, very straight forward change to the corrected syntax version of your SELECT statement. All you need to change is your FROM and what you are selecting. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 03, 2009 1:47 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
Of course, it would have to be proper ESQL SELECT syntax, which the example shown is not.
|
Hence my use of the phrase "something like" _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|