View previous topic :: View next topic |
Author |
Message |
vinothenator_1782 Beginner
Joined: 19 May 2006 Posts: 14 Topics: 4
|
Posted: Sat Aug 01, 2009 6:53 am Post subject: Question on cursor - avoiding 'order by' |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sun Aug 02, 2009 7:39 pm Post subject: |
|
|
vinothenator_1782,
Are we talking about CICS transaction? Remember that CICS transactions are pseudo conversational.
kolusu |
|
Back to top |
|
|
vinothenator_1782 Beginner
Joined: 19 May 2006 Posts: 14 Topics: 4
|
Posted: Mon Aug 03, 2009 1:49 am Post subject: |
|
|
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 |
|
|
vinothenator_1782 Beginner
Joined: 19 May 2006 Posts: 14 Topics: 4
|
Posted: Mon Aug 03, 2009 2:16 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Aug 03, 2009 3:04 pm Post subject: |
|
|
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 |
|
|
|
|