DB2 program calls subprogram cursor

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
ashadwivedi24
Member
Posts: 2
Joined: Fri Mar 30, 2012 2:03 pm
Location: gurgaon

DB2 program calls subprogram cursor

Post by ashadwivedi24 » Tue Oct 23, 2012 10:43 pm

If we call a subprogram from a program, and a cursor is defined in main program. Can we use the same cursor in subprogram or do we need to redefine the cursor in subprogram?

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Tue Oct 23, 2012 10:53 pm

1. REDEFINE is a COBOL keyword. It is used to map the same memory differently.

2. CURSORs are DB2 objects, qualified by the plan name (module).
even though the attributes of cursor definition in two separate modules (plans) are the same, does not mean they are the same cursor.

3. if the sub-module needs the data values
returned from a FETCH of the CURSOR defined in the main program,
why not pass the data in the CALL.

anytime you think you need to define the 'same' (same select/from/where) cursor in two different modules,
you are already in a false path.
you need to rethink your logic.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Oct 24, 2012 2:37 pm

Dick has given you a good explanation, however, I'm thinking why did not you try it before posting, unless it's an interview question.
Regards,
Anuj

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others