Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 1868
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: 6968
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: 1281
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 Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am
No new posts Adding a userid to SMTP Security table Yolanda Harvey JCL & VSAM 1 Sun Aug 13, 2017 6:16 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us