MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Loading a cursor into a Cobol internal table

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
sri50131
Beginner


Joined: 07 Oct 2004
Posts: 38
Topics: 15

PostPosted: Thu Oct 07, 2004 9:42 am    Post subject: Loading a cursor into a Cobol internal table Reply with quote

Hello,

I need to dump the result of the cursor in my program into an interanl table? I have declared an internal table as follows:

01 TEMP-TBL.
05 WS-TEMP-TBL OCCURS 1000 TIMES INDEXED BY X1.
10 WS-COVERAGE PIC X(20).
10 WS-ENDORSEMENT PIC X(10).

The fetch statement is as follows:

EXEC SQL
FETCH ENDRSCURS
INTO :WS-COVERAGE
,:WS-ENDORSEMENT
END-EXEC.

Since the above to columns are part of the internal table, I have to use a subscript, but I cannot subscript in the Fetch. Can you please let me know how to do it?

Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Thu Oct 07, 2004 9:57 am    Post subject: Reply with quote

sri50131,

Try this

Code:

01 DB2-COVERAGE       PIC X(20).
01 DB2-ENDORSEMENT    PIC X(10)
01 S-EOF-CURSOR       PIC X(01) VALUE 'N'
01 W-SUB              PIC S9(09) COMP VALUE ZERO.

PERFORM 100-OPEN-CURSOR
PERFORM 200-FETCH-CURSOR
PERFORM 300-LOAD-INTERNAL-TABLE UNTIL S-EOF-CURSOR = 'Y'

200-FETCH CURSOR.
   EXEC SQL
        FETCH ENDRSCURS
         INTO :DB2-COVERAGE
             ,:DB2-ENDORSEMENT
   END-EXEC.

300-LOAD-INTERNAL-TABLE

   ADD +1 TO W-SUB.
   MOVE DB2-COVERAGE     TO WS-COVERAGE(W-SUB)
   MOVE DB2-ENDORSEMENT  TO WS-ENDORSEMENT(W-SUB)
   PERFORM 200-FETCH-CURSOR
   .



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group