View previous topic :: View next topic
|
Author |
Message |
Minu Raju
New User
Joined: 05 Apr 2011 Posts: 3 Location: India
|
|
|
|
Hi All,
I have to implement a Cobol-DB2 program, to update a particular table. I am selecting records from the table using a cursor and updating it in the program. I need to code a restart logic for this program, but my issue is that the table doesn't have a primary key to store in a file or table to identify the record in case of abend and to continue process. I need to issue commit at an interval of 10 records. So once commit is successful i need to write to my restart file with the unique or primary key associated with the 10th row. This is my requirement.
I have checked for the table index also, and the Unique rule is D(means duplicates are allowed). I am having 5 columns in the index list, If i use an ORDER BY clause in my select query with the 5 columns in INDEX, will it help me somehow?
Has anybody face this kind of situation? Please share your thoughts on this.
This is the cursor:
DECLARE Cur1 CURSOR WITH HOLD FOR
Select * from Table A
where upper(field_x) like '%XYZ%'
AND DATE_FIELD =' '
ORDER BY FIELD1,FIELD2,FIELD3,FIELD4,FIELD5 |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Where does the information that you are updating the table with come from? If a sequential dataset hen record the number of records processed. On restart, skip that number of records.
More info needed. |
|
Back to top |
|
|
Minu Raju
New User
Joined: 05 Apr 2011 Posts: 3 Location: India
|
|
|
|
Nic-
I am using the same table for selecting and updating the rows. No files are used in the process. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
two posts and you still have not explained what your update is.
maybe, if you include the criteria in the where clause, you could exclude those that have been updated. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
if FIELD1,FIELD2,FIELD3,FIELD4,FIELD5 is not unique you might consider not to commit every 10th row but on every 10th or 5th break of FIELD1,FIELD2,FIELD3,FIELD4,FIELD5. |
|
Back to top |
|
|
vadim vashchenko
New User
Joined: 21 Mar 2011 Posts: 13 Location: usa
|
|
|
|
GuyC wrote: |
if FIELD1,FIELD2,FIELD3,FIELD4,FIELD5 is not unique you might consider not to commit every 10th row but on every 10th or 5th break of FIELD1,FIELD2,FIELD3,FIELD4,FIELD5. |
Speaking of the commit frequency - it makes sense to put the value into a DB2 table and play with it until you achieve the best performance. Not so relevant to the topic though... |
|
Back to top |
|
|
Minu Raju
New User
Joined: 05 Apr 2011 Posts: 3 Location: India
|
|
|
|
Hi All,
Thanks for the response.
I have got it confirmed that the 5 index columns will act as a unique record in real scenario. So planning to go ahead with ORDER BY clause in the CURSOR with 5 index columns. |
|
Back to top |
|
|
|