HI.
My DB2 stored procedure will return a cursor to calling COBOL program.
How do I defince the host variable to access the cursor?
Thanks.
how do i define the locator for cursor returned by SP
Moderators: dbzTHEdinosauer, Moderator Group
cobol db2 stored procedure
Here is some example to call db2 stored procedure from cobol program
Code: Select all
EXEC SQL
01 LOC1 SQL TYPE IS RESULT-SET-LOCATOR VARYING
END-EXEC.
.
.
PROCEDURE DIVISION.
.
.
EXEC SQL
CALL MYSCHEMA.P1
END-EXEC
EXEC SQL
ASSOCIATE LOCATOR (:LOC1) WITH PROCEDURE MYSCHEMA.P1;
END-EXEC.
..
..
EXEC SQL
ALLOCATE CURSOR1 CURSOR
FOR RESULT SET :LOC1
END-EXEC.
.
.
FETCH LOC1 INTO :XXX
Natarajan
Chennai
Chennai
Thanks for you reply.
The precompiler does not like 01 in
EXEC SQL
LOC1 SQL TYPE IS RESULT-SET-LOCATOR VARYING
END-EXEC.
so I took it out and it worked. However the ASSOCIATE and ALLOCATE statements expect a host variable. The statements below fails at precompile since :LOC1 is not defined.
EXEC SQL
ASSOCIATE LOCATOR (:LOC1) WITH PROCEDURE MYSCHEMA.P1;
END-EXEC.
..
..
EXEC SQL
ALLOCATE CURSOR1 CURSOR
FOR RESULT SET :LOC1
END-EXEC.
The precompiler does not like 01 in
EXEC SQL
LOC1 SQL TYPE IS RESULT-SET-LOCATOR VARYING
END-EXEC.
so I took it out and it worked. However the ASSOCIATE and ALLOCATE statements expect a host variable. The statements below fails at precompile since :LOC1 is not defined.
EXEC SQL
ASSOCIATE LOCATOR (:LOC1) WITH PROCEDURE MYSCHEMA.P1;
END-EXEC.
..
..
EXEC SQL
ALLOCATE CURSOR1 CURSOR
FOR RESULT SET :LOC1
END-EXEC.
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page