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

Fetching data from cursor


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

New User


Joined: 28 Jun 2006
Posts: 8

PostPosted: Thu Sep 21, 2006 7:26 pm
Reply with quote

Hi All,

I am working on mainframe environment using the Database as DB2. Following is the declaration of my cursor.

Code:
EXEC SQL                                                         
    DECLARE CNTRPT CURSOR FOR                                   
    SELECT DEPT_ID,                                             
                DEPT_GRP_NBR                                       
    CASE DEPT_STAT_CDE                                           
             WHEN 10 THEN SET :WS-PAID-CNT = COUNT(*)               
             WHEN 11 THEN SET :WS-ADJ-CNT  = COUNT(*)               
    END                                                         
    FROM  DEPT_DTL                                     
    WHERE DEPT_DTL.CUST_ID      = :PARM-CUST  AND
               DEPT_DTL.TRNS_CDE    = 'P' 
                                                                           
    GROUP BY DEPT_ID,                                           
                    DEPT_GRP_NBRR,                                   
                    DEPT_AFFL_ID                                       
    ORDER BY DEPT_ID,                                           
                    DEPT_GRP_NBRR                                     
END-EXEC.

***********************************************************

While fetching data from the cursor can i use the following way?

Code:
EXEC SQL
         FETCH CNTRPT               
                 INTO :DB-NF-DEPT_ID,     
                         :DB-NF-DEPT_GRP_NBR,
                         :DB-NF-PAID-CNT,
                         :DB-NF-ADJ-CNT
END-EXEC


Can i retrieve the data of the variable :WS-PAID-CNT into
DB-NF-PAID-CNT?

Could you please calrify me in this regard.

Thanks,
Ravi.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Oct 27, 2006 9:19 am
Reply with quote

Quote:
Can i retrieve the data of the variable :WS-PAID-CNT into
DB-NF-PAID-CNT?

Yes, if defined properly. Did you try that ?

Check Declaring Host Variables... & Using Host Variables...
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Format data from multiple records usi... SYNCSORT 4
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts Structured Data and Nested Loops via ... COBOL Programming 0
No new posts Alternate key data extracttion COBOL Programming 13
No new posts db2 vs static data COBOL Programming 1
Search our Forums:


Back to Top