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 » How to use Cursor in ESQL

Post new topic  Reply to topic
 How to use Cursor in ESQL « View previous topic :: View next topic » 
Author Message
Harshalw
PostPosted: Fri Jul 25, 2008 5:56 am    Post subject: How to use Cursor in ESQL Reply with quote

Voyager

Joined: 23 Jul 2008
Posts: 77

Hi,

I am using ESQL and WMB 6.1. My query will fetch number of records (Rows) from database and for each row i have a different processing and later on updation. How can i use cursor in Esql for the same or any other methoda used in ESQL. Please let me know.

Thanks
Back to top
View user's profile Send private message
sridhsri
PostPosted: Fri Jul 25, 2008 6:31 am    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

One method I can think of is to store the result set in a scratch pad like LocalEnvironment. You could then calculate the cardinality of the rows and use a loop to process each row.
Back to top
View user's profile Send private message
Harshalw
PostPosted: Fri Jul 25, 2008 6:49 am    Post subject: Reply with quote

Voyager

Joined: 23 Jul 2008
Posts: 77

can you please elaborate on how i can do that?
I am new to WMB and Esql here
Back to top
View user's profile Send private message
sridhsri
PostPosted: Fri Jul 25, 2008 7:19 am    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

Alright here goes....

DECLARE count INTEGER 0;
DECLARE I INTEGER 1;

SET OutputLocalEnvironment.ResultSet[] = SELECT * from Database.table;
SET count = CARDINALITY(OutputLOcalEnvironment.ResultSet[]);

WHILE I < count DO
--process each row in the array OutputLocalEnvironment.ResultSet[I]
SET I = I + 1;
END WHILE;
Back to top
View user's profile Send private message
Harshalw
PostPosted: Fri Jul 25, 2008 7:30 am    Post subject: Reply with quote

Voyager

Joined: 23 Jul 2008
Posts: 77

hey thanks for your input

how can we access the column from OutputLocalEnvironment.ResultSet[I]

will it be OutputLocalEnvironment.ResultSet[I].column_name ?
Back to top
View user's profile Send private message
sridhsri
PostPosted: Fri Jul 25, 2008 8:30 am    Post subject: Reply with quote

Master

Joined: 19 Jun 2008
Posts: 297

Harshalw, I gave wrong you some advise. I apologize. The correct and and efficient way of doing this is by using references.

DECLARE count INTEGER 0;
DECLARE I INTEGER 1;
DECLARE ref REFERENCE TO OutputLocalEnvironment.ResultSet;

SET OutputLocalEnvironment.ResultSet[] = SELECT * from Database.table;
--you could inspect carinality before this line
SET ref = MOVE ref FIRSTCHILD;

WHILE LASTMOVE(ref) DO
--process the result set
MOVE ref NEXTSIBLING REPEAT TYPE NAME;
END WHILE;

To answer your question, you. It will be ref.<columnname>
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 » How to use Cursor in ESQL
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.