MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question on cursor - avoiding 'order by'

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
vinothenator_1782
Beginner


Joined: 19 May 2006
Posts: 14
Topics: 4

PostPosted: Sat Aug 01, 2009 6:53 am    Post subject: Question on cursor - avoiding 'order by' Reply with quote

Hi all,

I have a cursor for a select statement which retrieves records based on a condition. But my program needs to handle only 50 rows at a time to avoid transaction timeout. In this case, even if the cursor fetches 150 rows, my program/transaction will handle this in 3 invocations. Please find my cursor declaration below :

DECLARE C1 CURSOR FOR

SELECT A1
FROM TABLE1
WHERE A1 > :A1
AND B1 = 'N'
AND C1 = 'O'
FETCH FIRST 50 ROWS ONLY

Here in the above case, A1, B1, C1 are column names. A1 is the primary key. Say for eg B1 and C1 will have the values declared (i.e., N & O) for all rows. If i pass the 50th key after processing first 50 records in first invocation, to the second invocation and 100th key to the third invocation of transaction, i believe i can process all the 150 records without using order by clause since A1 is the primary key. Is my assumption correct ? Will i have any issues with this logic ? Also lets assume no inserts/deletes will be done at this time of cursor operation.

Also the other option is to keep the transaction active for 150 record processing, is it possible ? How to keep the tran active for a long time without it getting abended ?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Sun Aug 02, 2009 7:39 pm    Post subject: Reply with quote

vinothenator_1782,

Are we talking about CICS transaction? Remember that CICS transactions are pseudo conversational.

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vinothenator_1782
Beginner


Joined: 19 May 2006
Posts: 14
Topics: 4

PostPosted: Mon Aug 03, 2009 1:49 am    Post subject: Reply with quote

Yes Kolusu, its a CICS transaction and it is MQ triggered. So whenever a message is dropped in the queue my transaction will get triggered. Is my assumption on DB2 handling correct ? Please advise.
Back to top
View user's profile Send private message
vinothenator_1782
Beginner


Joined: 19 May 2006
Posts: 14
Topics: 4

PostPosted: Mon Aug 03, 2009 2:16 am    Post subject: Reply with quote

Hi Kolusu, went through some posts and i believe my assumption on DB2 part is wrong. Data can be stored differently from its index order in DB2. Using 'Order by' will degrade the performance since im going to handle only few records at any one invocation but the 'ordering' will be done for all records. Also CICS transaction may encounter RL** abend if it processes all records at one go and this being the reason the last processed key (say at 50 count) is put into queue so the tran picks up from the next key on processing during its invocation. Is there any other logic to handle this scenario. Please advise.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Aug 03, 2009 3:04 pm    Post subject: Reply with quote

vinothenator_1782,

You are wrong again. You still need the ORDER by clause. You really need to understand the concept of pseudo conversation in CICS

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group