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
 

 

Getting -501 sqlcode from in a db2 CICS program....

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
peek_deep

New User


Joined: 02 Jan 2007
Posts: 13
Location: india

PostPosted: Thu Jun 19, 2008 4:02 am    Post subject: Getting -501 sqlcode from in a db2 CICS program....
Reply with quote

Hi all,

Need your help to solve this issue. I have an issue as follows:

1. I have set some flags as follows

01 CURSOR-STATUS PIC X
88 CURSOR-OPEN VALUE 'O'
88 CURSOR-CLOSE VALUE 'C'
88 CURSOR-FETCH VALUE 'F'
88 CURSOR-NOTOPEN VALUE ' ' It is a space.

these above fields are part of my commarea which I pass and get it back after each call to subprogramss.

2. In my first step I am setting the CURSOR-OPEN to true and calling a sub program, inside the subprogram I have a condition if OPEN is successful set the FETCH flag to true and will fetch the first record as per the logic. Infact it is doing the same. this cursor is CSR1.

3. Now my control comes back to the mainprogram and by using some of the recenly fetched fields from the above subprogram I have to call an another subprogram which is again a cursor CSR2. For this I am again setting the CURSOR-OPEN to true and Now I fetch the first matched row and came back to the main program.

4. Here as per the requirement If there is a match I need to close the cursor i.e. CSR2 (You may think I could use single select in place of this cursor. Even I had the same thought, but unfortunately this subprogram which I am using is a existing one and I can not modify it). So to close the cursor in the mainprogram I set the CURSOR-CLOSE to true and again called the existing module. This 2nd call to the existing module with the CURSOR-CLOSE flag set to true closes the cursor and immediately sets the CURSOR-NOTOPEN to true.

5. So finally I have the cursor status in my main program as ' '.

6. Now I wanted to fetch the next record from my first subprogram. Since the corsor is in CURSOR-NOTOPEN status I set it again to CURSOR-FETCH to true and called the 1st subprogram.

7. It went through the fetch para but throw a SQLCODE of -501. I checked the logic. As per my knowledge the logic should work, but I am not sure where the 1st cursor is getting close.

Can anyone please help me in this regard

Thanks in advance
Deepak
Back to top
View user's profile Send private message

vv

New User


Joined: 06 Jan 2008
Posts: 10
Location: bangalore

PostPosted: Thu Jun 19, 2008 11:20 am    Post subject:
Reply with quote

what ever u r declere the cursor name is worng or mismatch.


check it clearly.

venkat.
Back to top
View user's profile Send private message
ascelepius

New User


Joined: 16 Jun 2008
Posts: 35
Location: bangalore

PostPosted: Thu Jun 19, 2008 11:46 am    Post subject: Reply to: Getting -501 sqlcode from in a db2 CICS program...
Reply with quote

Oops I couldnt complete that,

I Main program
a. Open cursor CSR1
b. Call Sub-program 1
II Sub-program 1
a. fetch record
b. return data
III Main program
a. Open cursor CSR2
b. Call Subprogram 2
IV Sub-program2
a. fetch record
b. return data
V Main program
a.Compare data from CSR1 and CSR2
b. close CSR2
c.Call Sub-program 1

And you have a problem while fetching CSR1 again. Am I correct?

thanks,
asci(i)
Back to top
View user's profile Send private message
peek_deep

New User


Joined: 02 Jan 2007
Posts: 13
Location: india

PostPosted: Thu Jun 19, 2008 2:09 pm    Post subject:
Reply with quote

Yes, The flow you understood is correct and I am getting -501 when trying to fetch the second record from the CSR1.
Back to top
View user's profile Send private message
ascelepius

New User


Joined: 16 Jun 2008
Posts: 35
Location: bangalore

PostPosted: Thu Jun 19, 2008 2:15 pm    Post subject: Reply to: Getting -501 sqlcode from in a db2 CICS program...
Reply with quote

It could help if you could share your cursor declaration...
Meanwhile, since I have some time to kill let me try to replicate this situation

regards,
asci(i)
Back to top
View user's profile Send private message
peek_deep

New User


Joined: 02 Jan 2007
Posts: 13
Location: india

PostPosted: Thu Jun 19, 2008 2:44 pm    Post subject:
Reply with quote

Hi ASCI,

any cursor you can take. The only doubt I am having is why the first cursor is getting close, where as I am closing the cursor2. Even I crossed check the program again and I feel the logic should go through...
Back to top
View user's profile Send private message
peek_deep

New User


Joined: 02 Jan 2007
Posts: 13
Location: india

PostPosted: Thu Jun 19, 2008 3:04 pm    Post subject:
Reply with quote

I am using a Goback in the sub program. Is is causing the problem... I mean is it closing the cursor.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jun 19, 2008 4:56 pm    Post subject:
Reply with quote

Did any other sqlerror occur before your second fetch ??? .... if not try declaring your cursor with option WITH HOLD ...
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jun 19, 2008 4:58 pm    Post subject:
Reply with quote

If its a CICS psuedo conversational transaction you may have to convert it to conversational to keep the cursor open ...
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 CICS transaction slow response time vasanthz All Other Mainframe Topics 2 Thu Jan 19, 2017 1:31 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts INDEPENDENT CICS TS 4.1 MRO REGION UP... Kyle Carroll CICS 0 Wed Dec 14, 2016 6:55 pm
No new posts CICS START AND CANCEL blayek CICS 1 Wed Dec 07, 2016 3:27 am


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