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

COBOL cursor not processing from the check point


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 6966
Location: porcelain throne

PostPosted: Tue Mar 18, 2008 9:40 pm
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
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

Moderator Emeritus


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

PostPosted: Wed Mar 19, 2008 12:45 am
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
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: 6966
Location: porcelain throne

PostPosted: Wed Mar 19, 2008 5:00 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Point and Shoot )PTNS TSO/ISPF 0
Search our Forums:

Back to Top