- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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
How will you detect the condition of the end of cursor rows in a COBOL-DB2 program?
The cursor can be used to fetch multiple rows from a DB2 table. However, we have to fetch this cursor in a loop so that values corresponding to a single row are assigned to host variables at a time. Based on this logic we have to process our loop till the cursor reaches the last row result.
The SQLCODE field takes the value as 100 when there are no more rows left in the cursor to be fetched. Practically, we can implement this in the following way.
SET WF-END-CURSOR-N TO TRUE PERFORM UNTIL WF-END-CURSOR-Y EXEC SQL FETCH ORDER_CUR INTO :ORDER-ID END-EXEC IF SQLCODE = 100 SET WF-END-CURSOR-Y TO TRUE ELSE PERFORM A20-PROCESS-RECORD END-IF END-PERFORM
WF-END-CURSOR-Y and WF-END-CURSOR-N are two flags at 88 level which is used to control the loop. Once the SQLCODE has the value 100 that means the cursor has reached at the last row and loop is terminated.
- Related Articles
- How will you keep the CURSOR open after firing COMMIT in a COBOL-DB2 program?
- How can you revert all the DB2 table changes done in a COBOL-DB2 program?
- What are the steps involved to use a CURSOR in any COBOL-DB2 program?
- How will the COBOL-DB2 program behave if the DCLGEN member is not included?
- How to precompile a COBOL-DB2 program?
- Impact of database downtime on the COBOL-DB2 program
- Steps involved in compilation of a COBOL-DB2 program
- Implementation of restart logic in a COBOL-DB2 program
- What is the purpose of the "FOR UPDATE OF" clause in a cursor? What will happen if we fire an UPDATE statement without using this clause in a COBOL-DB2 program?
- What will be the result if SQLCA is not included in a COBOL-DB2 program?
- How to execute a COBOL-DB2 program PROGA of plan PLANA?
- Behaviour of a COBOL-DB2 program when number of locks exceed the limit
- How to use SQLCA in a COBOL-DB2 program? What is the purpose of SQLCA?
- How LOST UPDATE and DIRTY READ impact the processing of a COBOL-DB2 program?
- Purpose and usage of SAVEPOINT in COBOL-DB2 program