ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL Syntax Question

Post new topic  Reply to topic Goto page 1, 2  Next
 ESQL Syntax Question « View previous topic :: View next topic » 
Author Message
jayZ
PostPosted: Fri Jan 11, 2013 11:02 am    Post subject: ESQL Syntax Question Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

Suppose I have this XML:

<Message>
<Data Type=Text>
<Value/>
<Value/>
</Data>
<Data Type=Number>
<Value/>
<Value/>
</Data>
</Message>

What would be the ESQL syntax to create a reference for only data records where the type = ‘Text'?
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Jan 11, 2013 11:08 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

If Data Type equals text then set the records values.

You don't really expect us to code this for you? Are you getting paid to do a job?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
jayZ
PostPosted: Fri Jan 11, 2013 11:12 am    Post subject: Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

Look, there is no need for the snark. Have you ever come across a piece of code in your job you know you should know but for some reason couldn't? It's a simple syntax question that I just happen to be spacing on. I am a certified broker developer with 8 years of experience and don't need my intelligence insulted.

I can create a reference to all data elements. I just didn't know how to filter out which elements are included in the reference by attribute.

Either offer help or don't answer.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Jan 11, 2013 11:20 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

What syntax have you tried? If you want help - you need to be the one working, not us.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER


Last edited by lancelotlinc on Fri Jan 11, 2013 11:35 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
jayZ
PostPosted: Fri Jan 11, 2013 11:25 am    Post subject: Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

While we're at it, I'll add it can do the same thing in XPath pretty easily:

/Message/Data[@Type='Text']/.

I can also loop through a reference containing all the fields or write a select statement to pick the one I want out AFTER declaring the reference. Both of those methods waste resources by messing with data I know I won't need.

I was thinking that I would try to handle this when I declare the reference; so i'm not looping through or storing in memory more than I need.

I'm messing with large messages here and lazy, inefficient code won't cut it.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jan 11, 2013 11:25 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The esql MOVE statement doesn't take a where qualifier that would let you say 'move to the next Data element who's Type attribute is "Text"'.

So you kind of have to move to the next Data element and check the type attribute.
Back to top
View user's profile Send private message
jayZ
PostPosted: Fri Jan 11, 2013 11:27 am    Post subject: Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

Believe what you want, it's true.

Instead of being so full of yourself, you might consider I gave a stupid example to simplify the question.

Why not send me another shortcut, wasteful suggestion again? That way you can feel smart.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Jan 11, 2013 11:31 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

ESQL might not provide the most efficient solution. If efficiency is your priority, then you might consider alternative Transformation logic languages like Java or .Net.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
jayZ
PostPosted: Fri Jan 11, 2013 11:32 am    Post subject: Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

Thanks, mqjeff. I appreciate the thoughtful answer. We've worked together on here before and you've always given thoughtful answers. Sorry you had to read through the other stuff.

Anyway...

Because we could be dealing with a nested loop (Multiple 'Data' elements, then multiple 'Value' elements), i was hoping to declare a reference for the outter that would only return one list of Values, then create another with all the values.

So, like this...

CREATE data REFERENCE TO Msg.Data[@Type = 'Text'];
CREATE val REFERENCE TO data.Value[1];

OR (even better)
CREATE val REFERENCE TO Msg.Data[@Type='Text'].Value[1];

Then, when I loop through my val reference, I only get valid Data pieces.

Is the latter possible?
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Jan 11, 2013 11:37 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

jayZ wrote:
Thanks, mqjeff. I appreciate the thoughtful answer. We've worked together on here before and you've always given thoughtful answers. Sorry you had to read through the other stuff.

Anyway...

Because we could be dealing with a nested loop (Multiple 'Data' elements, then multiple 'Value' elements), i was hoping to declare a reference for the outter that would only return one list of Values, then create another with all the values.

So, like this...

CREATE data REFERENCE TO Msg.Data[@Type = 'Text'];
CREATE val REFERENCE TO data.Value[1];

OR (even better)
CREATE val REFERENCE TO Msg.Data[@Type='Text'].Value[1];

Then, when I loop through my val reference, I only get valid Data pieces.

Is the latter possible?


What was wrong with posting this information at the first ? This demonstrates you have invested effort into thinking and trying a solution. If you've been reading the forum this week, you'll notice a bombardment of 'can you do my job posts'.

http://www.mqseries.net/phpBB2/viewtopic.php?t=63169
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
jayZ
PostPosted: Fri Jan 11, 2013 11:46 am    Post subject: Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

I'd rather focus on the solution and not waste any more time on this side-conflict that will only turn people off who actually want to help. To address your question, though, I posted what I did to get an answer to a simple syntax answer that I assumed would take 2 seconds for someone to address. The fact that I already have a working solution would only take up space on the post and detract from what I was trying to ask.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jan 11, 2013 11:51 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

jayZ wrote:
Thanks, mqjeff. I appreciate the thoughtful answer. We've worked together on here before and you've always given thoughtful answers. Sorry you had to read through the other stuff.

Anyway...

Because we could be dealing with a nested loop (Multiple 'Data' elements, then multiple 'Value' elements), i was hoping to declare a reference for the outter that would only return one list of Values, then create another with all the values.

So, like this...

CREATE data REFERENCE TO Msg.Data[@Type = 'Text'];
CREATE val REFERENCE TO data.Value[1];

OR (even better)
CREATE val REFERENCE TO Msg.Data[@Type='Text'].Value[1];

Then, when I loop through my val reference, I only get valid Data pieces.

Is the latter possible?


Not directly.

But you can do something like
Code:

For Msg.Data[] as data
    if data.(XMLNSC.Attribute)Type = 'Text' THEN
        for value as ...
Back to top
View user's profile Send private message
jayZ
PostPosted: Fri Jan 11, 2013 12:04 pm    Post subject: Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

Thanks, Jeff. That's actually exactly how I had it originally. At least I don't have to make any changes :)

I appreciate your time!
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Jan 11, 2013 9:19 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

jayZ wrote:
Thanks, Jeff. That's actually exactly how I had it originally. At least I don't have to make any changes

I appreciate your time!


Ifyou had this solution in the first place why on earth didn't you say so?
Your original question could have been phrased something like
Quote:

I have this structure...

I'm using this ESQL....

Is this a good solution?

As my colleague has said, there have been a number of 'can you do my job' posts this week. On the face of it, your original post is just like that. If you had asked the question differently (as suggested above for example) then you might have gotten the answer you were looking for a bit quicker.

The old Yokshire saying comes to mind, 'There are nowt as queer as folk'.
_________________
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
View user's profile Send private message
jayZ
PostPosted: Sat Jan 12, 2013 6:15 am    Post subject: Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

The only thing worse than a 'do my job for me' question is answering the same question twice. Not only did I answer that exact question earlier in the thread, but I also explained that it was irrelevant. It isn't my fault that he/you wanted to assume I was stupid so that he/you could feel smart. In the spirit on teaching, here are some ways you could have better responded:

1) Do you have a working solution in place?
2) Forum guidelines require you post more information on what you've tried; please provide more info.
3) No response at all

I had a specific solution in mind (One that I knew would be best and possible through other means) and I asked about it. Now, please let's not pile on and make me wake up to annoying posts on a weekend. I'm sure you have plenty of unanswered questions that would be more deserving of your time.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL Syntax Question
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.