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
 

 

COBOL cursor not processing from the check point

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
maheshk84

New User


Joined: 04 Jan 2006
Posts: 22
Location: Chennai

PostPosted: Tue Mar 18, 2008 9:02 pm    Post subject: COBOL cursor not processing from the check point
Reply with quote

Hi,

I am changing a COBOL program.
There is a cursor which reads the whole table and processes it.
Current cursor used:
1)move low-values to host-timestamp
2) cursor -->
select * from table
where timestamp > host-timestamp
order by timestamp;
3) process the rows.

I need to change the program so that it reads the last 40 rows
order by timestamp.
One of the methods that I ve followed.
1) introduce a new cursor - order by timestamp desc
2) loop 40 times and get the timestamp of the last iteration --> host1-timestamp
3) move host1-timestamp to host-timestamp
4) execute the old cursor.

When I do this, the cursor starts from the beginning and not
the start point(timestamp) that I ve created.

Please let me know if I am not clear.
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 18, 2008 9:05 pm    Post subject:
Reply with quote

Low values would be an invalid value for a timestamp!
Back to top
View user's profile Send private message
maheshk84

New User


Joined: 04 Jan 2006
Posts: 22
Location: Chennai

PostPosted: Tue Mar 18, 2008 9:12 pm    Post subject:
Reply with quote

HI Craq,

They have hard coded the low values as below.
01 H-TIMESTAMP PIC X(26).
01 WS-LOW-TIMESTAMP PIC X(26)
VALUE '0001-01-01-00.00.00.000000'.


MOVE WS-LOW-TIMESTAMP TO H-TIMESTAMP.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Mar 18, 2008 9:40 pm    Post subject:
Reply with quote

1. if you are going to ask professionals questions about 'their' topic (mainframe), use their jargon.


LOW-VALUES is hex'00' for whatever length required.

your WS-LOW-TIMESTAMP is just the 'earliest' timestamp acceptable to db2.

how about ORDER BY <timestamp column> DESC
optimize for 40 rows?

since you have no idea how 'old' the 40th Timestamp is, your stuck with complete cursor, which is dumb. The must be a way to determine where the cut-off is.


now, I think this is a student project, because I can not see a business reason to select the 'oldest' 40 timestamps.
Back to top
View user's profile Send private message
maheshk84

New User


Joined: 04 Jan 2006
Posts: 22
Location: Chennai

PostPosted: Tue Mar 18, 2008 9:52 pm    Post subject:
Reply with quote

Hi,

This is not a student project. There IS a business reason behind it. One of the programs in prod is erring as the array is blown. The business doesnot agree either to delete the rows or increase the array size. So I had chosen this one to proceed with the problem. Please let me know if you know anyother way.

When you say "optimize for 40 rows", Is that DB2 SQL command or a general term you are mentioning.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Mar 19, 2008 12:45 am    Post subject:
Reply with quote

Hello,

Quote:
3) move host1-timestamp to host-timestamp
4) execute the old cursor.
I'd suggest you display the host-timestamp after 3).

Is there any possibility thet the "old" initial value is being moved back into the host-timestamp before the "old cursor" is executed?
Back to top
View user's profile Send private message
maheshk84

New User


Joined: 04 Jan 2006
Posts: 22
Location: Chennai

PostPosted: Wed Mar 19, 2008 4:17 pm    Post subject:
Reply with quote

Dick,

Thanks for your suggestion. When I put the displays, all showed the correct values. But for some reason, the cursor did not start from the checkpoint rather it started from the first.

I found that the cursor was already open. This was the reason behind this error. So whatever values moved to the host variables were not picked up. Now, I have just shifted the new lines before opening the cursor. It works now. It's my mistake. Sorry to bother you all. Cheers. icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Mar 19, 2008 5:00 pm    Post subject:
Reply with quote

maheshk84,

1. most mistakes are minor, things we overlook or take for granted. I have not found many 'deep technical' problems in a quite a while. Most is violation of syntax or 'poor' logic.

2. thx for getting back with the answer.

3. you did not bother us. you needed some help, we supplied what help we could, you responded by solving your own problem. can not ask for more.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am


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