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 select against Environment.Resultset[] question

Post new topic  Reply to topic
 ESQL select against Environment.Resultset[] question « View previous topic :: View next topic » 
Author Message
pcelari
PostPosted: Thu Mar 05, 2009 3:00 pm    Post subject: ESQL select against Environment.Resultset[] question Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

Hi,

in a compute node, a call to a stored procedure returns a resultset stored in the Environment.Resultset[].

I need to retrieve only one row that contains a particular value. So I use the following select statement to achieve that:

set s = select T.ITEMDESC
FROM Environment.ResultSet[] AS T
where T.TYPE = '2';

But at deploy time, I got the following failure report about the statement about my use of Environment.ResultSet[]

"Illegal data type for target. A list field reference is required.
The expression supplying the target must evaluate to a value of a suitable type. The given expression cannot possibly do so."

If I remove the "[]", it deploys successfully, but I get nothing back and T points to the first row only, which doesn't meet the condition.

Is it possible to use select statement against a resultset at all?

Of course, I can use the while loop to go over all rows until the match is found. But a select statement would be so simple.

any insight would be greatly appreciated.


_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
mgk
PostPosted: Thu Mar 05, 2009 3:13 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Yes this can work, but to construct the correct query I need to see the format of the data in the Envrionment.ResultSet.

Can you post the output of a trace node showing the Environment tree please.
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
pcelari
PostPosted: Thu Mar 05, 2009 5:16 pm    Post subject: Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

Here's the output of ${Environment}

( ['MQROOT' : 0x20022a8e650]
(0x01000000:Name):ResultSet = (
(0x03000000:NameValue):ITEM_ID = '46201' (CHARACTER)
(0x03000000:NameValue):TYPE = '0' (CHARACTER)
(0x03000000:NameValue):ITEMDESC = 'Base Price' (CHARACTER)
(0x03000000:NameValue):VALUE = '231.99' (CHARACTER)
)
(0x01000000:Name):ResultSet = (
(0x03000000:NameValue):ITEM_ID = '46201' (CHARACTER)
(0x03000000:NameValue):TYPE = '1' (CHARACTER)
(0x03000000:NameValue):ITEMDESC = 'Availability'
(0x03000000:NameValue):VALUE = 'Y' (CHARACTER)
)
(0x01000000:Name):ResultSet = (
(0x03000000:NameValue):ITEM_ID = '46201' (CHARACTER)
(0x03000000:NameValue):TYPE = '2' (CHARACTER)
(0x03000000:NameValue):ITEMDESC = 'Commercial Toaster'
(0x03000000:NameValue):VALUE = '' (CHARACTER)
)
)
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
m.schneider
PostPosted: Fri Mar 06, 2009 12:25 am    Post subject: Reply with quote

Centurion

Joined: 10 Apr 2007
Posts: 132
Location: Germany

You can use THE in the select

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=/com.ibm.etools.mft.doc/ak05587_.htm
Back to top
View user's profile Send private message
pcelari
PostPosted: Fri Mar 06, 2009 5:48 am    Post subject: Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

thanks for the suggestion.

But the THE function didn't work either, as it returns only the first in the list, or empty, which is what I get with the select stmt.
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri Mar 06, 2009 3:17 pm    Post subject: Re: ESQL select against Environment.Resultset[] question Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

pcelari wrote:
I need to retrieve only one row that contains a particular value. So I use the following select statement to achieve that:
Code:
set s = select T.ITEMDESC
           FROM Environment.ResultSet[] AS T
           where T.TYPE = '2';

How is s declared?

pcelari wrote:
But at deploy time, I got the following failure report about the statement about my use of Environment.ResultSet[]
Code:
"Illegal data type for target. A list field reference is required.
The expression supplying the target must evaluate to a value of a suitable type. The given expression cannot possibly do so."

It is not the use of Environment.ResultSet[] that is generating the error; it is the use of s.

pcelari wrote:
But the THE function didn't work either, as it returns only the first in the list, or empty, which is what I get with the select stmt.

If s is scalar, then the THE function probably works much better with ITEM in the SelectClause of the SELECT function.
Back to top
View user's profile Send private message
flahunter
PostPosted: Mon Mar 09, 2009 12:56 am    Post subject: Reply with quote

Acolyte

Joined: 30 Oct 2008
Posts: 62

What's the data type of s?
Back to top
View user's profile Send private message
pcelari
PostPosted: Mon Mar 09, 2009 9:43 am    Post subject: Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

it is of character type.
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
mgk
PostPosted: Mon Mar 09, 2009 11:31 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Then you will need to the both THE and ITEM with the select to ensure it returns a scalar value.
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
flahunter
PostPosted: Tue Mar 10, 2009 12:20 am    Post subject: Reply with quote

Acolyte

Joined: 30 Oct 2008
Posts: 62

Yes, something like this

set s = THE(select ITEM T.ITEMDESC
FROM Environment.ResultSet[] AS T
where T.TYPE = '2');
Back to top
View user's profile Send private message
pcelari
PostPosted: Wed Mar 11, 2009 11:54 am    Post subject: Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

Many thanks for all the insight!

the following code

set s = RTRIM (THE (select T.ITEMDESC
FROM Environment.ResultSet[] AS T
where T.TYPE = '2'));

delivers the correct result. It's so much simpler than the otherwise search and get loop.

declare M integer cardinality(Environment.ResultSet[]);
declare s char '';
X : WHILE i <= M DO
IF (Environment.ResultSet[i].TYPE = '2') THEN
set s = rtrim(Environment.ResultSet[i].ITEMDESC);
LEAVE X;
END IF;
set i = i + 1;
END WHILE X;
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL select against Environment.Resultset[] 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.