Author |
Message
|
anilmekala |
Posted: Fri Apr 17, 2015 12:45 am Post subject: Need help regarding Attribute value using esql |
|
|
Acolyte
Joined: 19 Oct 2012 Posts: 63
|
Hi ,
I hope every body doing good.
I have sample xml as below
<DATASTREAM.SEGMENTS index="1">19000160</DATASTREAM.SEGMENTS>
<DATASTREAM.SEGMENTS index="2">-1</DATASTREAM.SEGMENTS>
<DATASTREAM.SEGMENTS index="3"/>
<DATASTREAM.SEGMENTS index="4">I</DATASTREAM.SEGMENTS>
I want read DATASTREAM_SEGMENTS which index=1 through esql.
Please help me how to read that element.
Thanks in advance.
Regards,
Anil. |
|
Back to top |
|
 |
christopher j |
Posted: Fri Apr 17, 2015 1:30 am Post subject: |
|
|
Novice
Joined: 01 Jan 2010 Posts: 20
|
Have you tried ESQL select statement? |
|
Back to top |
|
 |
anilmekala |
Posted: Fri Apr 17, 2015 1:51 am Post subject: |
|
|
Acolyte
Joined: 19 Oct 2012 Posts: 63
|
Hi ,
thanks . I got solution with select statement.
Regards,
Anil. |
|
Back to top |
|
 |
wmbfrz |
Posted: Thu Jun 30, 2016 5:32 pm Post subject: |
|
|
Apprentice
Joined: 08 Jan 2010 Posts: 28
|
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Jun 30, 2016 10:11 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
wmbfrz wrote: |
What is the solution? |
What have you tried and what were the results? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
wmbfrz |
Posted: Fri Jul 01, 2016 12:55 am Post subject: |
|
|
Apprentice
Joined: 08 Jan 2010 Posts: 28
|
This is a sample message
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Sample>
<Total TotalType="TransactionGrandAmount">174.24</Total>
<Total TotalType="TransactionGrossAmount">174.24</Total>
<Total TotalType="TransactionNetAmount">174.24</Total>
<Total TotalType="TransactionTaxAmount">0</Total>
</Sample>
These are what i have tried.
SET tmp1 = THE ( SELECT ITEM C.Total FROM InputRoot.XMLNSC.Sample.Total.Item[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp2 = THE ( SELECT ITEM C.Total FROM InputRoot.XMLNSC.Sample.Total[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp1 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample.Total.Item[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp2 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample.Total[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
None of the above works. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jul 01, 2016 4:54 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
wmbfrz wrote: |
This is a sample message
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Sample>
<Total TotalType="TransactionGrandAmount">174.24</Total>
<Total TotalType="TransactionGrossAmount">174.24</Total>
<Total TotalType="TransactionNetAmount">174.24</Total>
<Total TotalType="TransactionTaxAmount">0</Total>
</Sample>
These are what i have tried.
SET tmp1 = THE ( SELECT ITEM C.Total FROM InputRoot.XMLNSC.Sample.Total.Item[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp2 = THE ( SELECT ITEM C.Total FROM InputRoot.XMLNSC.Sample.Total[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp1 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample.Total.Item[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp2 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample.Total[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
None of the above works. |
try
Code: |
SET tmp2 = THE ( SELECT C.Total VALUE FROM InputRoot.XMLNSC.Sample[] AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
-- or
SET tmp2 = THE ( SELECT FIELDVALUE(C.Total) FROM InputRoot.XMLNSC.Sample[] AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
|
_________________ MQ & Broker admin |
|
Back to top |
|
 |
wmbfrz |
Posted: Fri Jul 01, 2016 5:10 am Post subject: |
|
|
Apprentice
Joined: 08 Jan 2010 Posts: 28
|
No.. that doesnt works either. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jul 01, 2016 5:13 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
wmbfrz wrote: |
No.. that doesnt works either. |
Doesn't work how?
It crashes the EG? It makes your desk turn green? It uninstalls your screensaver?
Or it gives an error message... ? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
wmbfrz |
Posted: Mon Jul 04, 2016 1:11 am Post subject: |
|
|
Apprentice
Joined: 08 Jan 2010 Posts: 28
|
mqjeff wrote: |
wmbfrz wrote: |
No.. that doesnt works either. |
Doesn't work how?
It crashes the EG? It makes your desk turn green? It uninstalls your screensaver?
Or it gives an error message... ? |
I am wondering why you missed 'Alien Resurgence'! Jokes apart, the statements simply do not result in any value assigned to tmp and simply pass. |
|
Back to top |
|
 |
maurito |
Posted: Mon Jul 04, 2016 1:40 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
wmbfrz wrote: |
mqjeff wrote: |
wmbfrz wrote: |
No.. that doesnt works either. |
Doesn't work how?
It crashes the EG? It makes your desk turn green? It uninstalls your screensaver?
Or it gives an error message... ? |
I am wondering why you missed 'Alien Resurgence'! Jokes apart, the statements simply do not result in any value assigned to tmp and simply pass. |
If you run with a user trace it will soon become clear that your select is wrong.
for example
Code: |
SET tmp2 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample.Total[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount'); |
the dynamic reference C is pointing to InputRoot.XMLNSC.Sample.Total
therefore, if you
You are trying to get a value from
Code: |
InputRoot.XMLNSC.Sample.Total.Total |
|
|
Back to top |
|
 |
wmbfrz |
Posted: Mon Jul 04, 2016 10:26 pm Post subject: |
|
|
Apprentice
Joined: 08 Jan 2010 Posts: 28
|
maurito wrote: |
wmbfrz wrote: |
mqjeff wrote: |
wmbfrz wrote: |
No.. that doesnt works either. |
Doesn't work how?
It crashes the EG? It makes your desk turn green? It uninstalls your screensaver?
Or it gives an error message... ? |
I am wondering why you missed 'Alien Resurgence'! Jokes apart, the statements simply do not result in any value assigned to tmp and simply pass. |
If you run with a user trace it will soon become clear that your select is wrong.
for example
Code: |
SET tmp2 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample.Total[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount'); |
the dynamic reference C is pointing to InputRoot.XMLNSC.Sample.Total
therefore, if you
You are trying to get a value from
Code: |
InputRoot.XMLNSC.Sample.Total.Total |
|
Thanks for your reply. I tried the following based on your suggestion but got nothing in output.
SET tmp1 = THE ( SELECT ITEM C.Total FROM InputRoot.XMLNSC.Sample AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp2 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp1 = THE ( SELECT ITEM C.Total FROM InputRoot.XMLNSC.Sample[] AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp2 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample[] AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
-- |
|
Back to top |
|
 |
maurito |
Posted: Mon Jul 04, 2016 10:30 pm Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
wmbfrz wrote: |
SET tmp1 = THE ( SELECT ITEM C.Total FROM InputRoot.XMLNSC.Sample AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp2 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp1 = THE ( SELECT ITEM C.Total FROM InputRoot.XMLNSC.Sample[] AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
SET tmp2 = THE ( SELECT C.Total FROM InputRoot.XMLNSC.Sample[] AS C WHERE C.Total.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
-- |
NO. Sample is not an array of elements. Total IS.
So you need to change whatever is after SELECT and not what is after FROM
Please run with a user trace as suggested and READ it and work out why you are getting nothing. |
|
Back to top |
|
 |
wmbfrz |
Posted: Tue Jul 05, 2016 5:01 am Post subject: |
|
|
Apprentice
Joined: 08 Jan 2010 Posts: 28
|
Thanks. Got this working
SET tmp3 = THE ( SELECT ITEM C FROM InputRoot.XMLNSC.Sample.Total[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
But i noticed that it took me 4 stepovers to move from this statement instead of 3 regardless of using the ITEM keyword. I also tried to change the input message to have two items satisfying the condition but it alway took the third element's value but in 4 iterations. Can somebody please explain? |
|
Back to top |
|
 |
maurito |
Posted: Tue Jul 05, 2016 5:06 am Post subject: |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
wmbfrz wrote: |
Thanks. Got this working
SET tmp3 = THE ( SELECT ITEM C FROM InputRoot.XMLNSC.Sample.Total[] AS C WHERE C.(XMLNSC.Attribute)TotalType = 'TransactionNetAmount');
But i noticed that it took me 4 stepovers to move from this statement instead of 3 regardless of using the ITEM keyword. I also tried to change the input message to have two items satisfying the condition but it alway took the third element's value but in 4 iterations. Can somebody please explain? |
I don't know what you are trying to say with the number of iterations or stepovers, but you will get only ONE value because you are specifying THE and ITEM. Please refer to the SELECT statement for clarification.
And once again, if you are worried about number of iterations/stepovers, gather a user trace and you will see what is happening. |
|
Back to top |
|
 |
|