Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Restart Logic to be handled on a Table with No Primary Key
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: 1722
Location: UK

PostPosted: Wed Apr 06, 2011 2:17 pm    Post subject:
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    Post subject: Restart Logic to be handled on a Table with No Primary Key
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    Post subject:
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: 1278
Location: Belgium

PostPosted: Wed Apr 06, 2011 4:43 pm    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us