- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the steps involved to use a CURSOR in any COBOL-DB2 program?
The CURSOR is used when we have to fetch multiple rows from a table. There are 4 steps involved in order to use a cursor in a COBOL-DB2 program.
DECLARE cursor− In this step we will define the layout of the cursor. We will give the query we want to use. For example−
EXEC SQL DECLARE ORDER_CUR CURSOR FOR SELECT ORDER_ID FROM ORDERS WHERE ORDER_DATE = ‘2020-07-28’ END-EXEC
OPEN cursor− Next we will open our cursor. This statement readies the cursor for data retrieval. For example−
EXEC SQL OPEN ORDER_CUR END-EXEC
FETCH cursor− In this statement, we start fetching the data from DB2 and the row data is stored in host variables. The syntax is like below.
EXEC SQL FETCH ORDER_CUR INTO :ORDER-ID END-EXEC
CLOSE cursor− In this last step we close the cursor which will release all the resources held by the cursor.
EXEC SQL CLOSE ORDER_CUR END-EXEC
- Related Articles
- Steps involved in compilation of a COBOL-DB2 program
- How will you keep the CURSOR open after firing COMMIT in a COBOL-DB2 program?
- How to use SQLCA in a COBOL-DB2 program? What is the purpose of SQLCA?
- How will you detect the condition of the end of cursor rows in a COBOL-DB2 program?
- How to precompile a COBOL-DB2 program?
- What are the different steps involved to execute a Java program?
- Implementation of restart logic in a COBOL-DB2 program
- What are the different steps in using MySQL cursor?
- How can you revert all the DB2 table changes done in a COBOL-DB2 program?
- What are the Steps Involved in Effective Collection Procedure?
- Impact of database downtime on the COBOL-DB2 program
- How to execute a COBOL-DB2 program PROGA of plan PLANA?
- How to store a NULL value in a particular column of a DB2 table using COBOL-DB2 program?
- What will be the result if SQLCA is not included in a COBOL-DB2 program?
- Purpose and usage of SAVEPOINT in COBOL-DB2 program

Advertisements