IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Restart Logic to be handled on a Table with No Primary Key


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Minu Raju

New User


Joined: 05 Apr 2011
Posts: 3
Location: India

PostPosted: Wed Apr 06, 2011 1:44 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Apr 06, 2011 2:17 pm
Reply with quote

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
View user's profile Send private message
Minu Raju

New User


Joined: 05 Apr 2011
Posts: 3
Location: India

PostPosted: Wed Apr 06, 2011 2:33 pm
Reply with quote

Nic-

I am using the same table for selecting and updating the rows. No files are used in the process.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Apr 06, 2011 2:50 pm
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Apr 06, 2011 4:43 pm
Reply with quote

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
View user's profile Send private message
vadim vashchenko

New User


Joined: 21 Mar 2011
Posts: 13
Location: usa

PostPosted: Wed Apr 06, 2011 5:13 pm
Reply with quote

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
View user's profile Send private message
Minu Raju

New User


Joined: 05 Apr 2011
Posts: 3
Location: India

PostPosted: Thu Apr 07, 2011 1:18 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top