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

Problem in declaring cursor


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chk_varthi

New User


Joined: 28 Apr 2010
Posts: 2
Location: Hyderabad

PostPosted: Thu May 20, 2010 7:26 am
Reply with quote

Hi All,

My query is, there are 2 tables EMP & DEPT i have to declare a cursor using joins in a COBOL + DB2 program LIKE BELOW

EXEC SQL

DECLARE X CURSOR FOR SELECT T1.PNO, T2.PID FROM EMP T1, DEPT T2 WHERE T1.PNO = T2.PNO
END-EXEC

I am getting error SOC1 when opening the cursor. My assumption is that there is problem while DECLARE cursor highlighted above, instead of T1.PNO=T2.PNO we need to give some condition T1.PNO=????


Please suggest ASAP.Can pl send mail eAddr_removed@yahoo.com
Actual e-mail address removed
regards
CK
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: Thu May 20, 2010 7:42 am
Reply with quote

Hello and welcome to the forum,

Due to problems in the past, we remove user e-mail addresses.

Why do you believe the s0c1 happens when opening this cursor?

What diagnostic information might have been generated by then pre-compile, compile, link, or bind?

We don't do ASAP,do please don't ask. . .
Back to top
View user's profile Send private message
chk_varthi

New User


Joined: 28 Apr 2010
Posts: 2
Location: Hyderabad

PostPosted: Thu May 20, 2010 9:02 am
Reply with quote

Hi,

I am giving the declare cursor coded in my program.
I am trying to declare a cursor using joins.

EXEC SQL
DECLARE L_CURSOR CURSOR FOR
SELECT C.PRFL_NBR,
C.USERID,
C.CHNNL_ID,
A.ATTCH_ACCT_NBR
FROM CENTRY C, ACCT A
WHERE
C.PRFLNBR = A.PRFLNBR

END-EXEC

EXEC SQL
OPEN L_CURSOR
END-EXEC



I am getting error when it came to OPEN cursor with SOC1 error. I think while declaring the cursor using joins is a problem. Can anyone help regarding this issue. How to declare cursor for the above condition

regards
CK
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: Thu May 20, 2010 9:10 am
Reply with quote

Hello,

It does no good to repeat the original post and not provide the requested answers. . .

Cursors often process a result set that is from a join. . .
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu May 20, 2010 12:31 pm
Reply with quote

actually, a declare cursor, does not execute any code.
the code generated by the db2 pre-compiler is executed, normally once,
at the very beginning of the program - before your first coding statement.

So, to say the OPEN is receiving a S0C1 because of the declare is rather
................

Take a look at why you receive S0C1 from the operating system.
Though you are receiving the error upon a CALL to db2,
solve your problem based on why a S0C1 can be issued.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri May 21, 2010 6:28 pm
Reply with quote

search forum ?
www.ibmmainframes.com/viewtopic.php?t=46003&highlight=s0c1
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Need to add field to copybook, proble... COBOL Programming 14
Search our Forums:

Back to Top