- 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 extract multiple rows from a DB2 table in a single FETCH call?
We can extract multiple rows from a DB2 table in a single FETCH call using a concept of multi row fetch.
In a multi row fetch, we have to declare the cursor with the clause “WITH ROWSET POSITIONING”. The host variable in this case should be declared as an array.
Therefore, in a single fetch statement the host variable array will be populated with the multiple row data. We can traverse in the host variable array in order to access this row data.
For example, we can declare a multi fetch cursor like below−
EXEC SQL DECLARE ORDER_CUR WITH ROWSET POSITIONING FOR SELECT ORDER_ID FROM ORDERS WHERE ORDER_DATE = ‘2020-07-28’ END-SQL
- Related Articles
- Fetch random rows from a table with MySQL
- How to fetch only a single result from a table in Java-MySQL?
- How to insert multiple rows in a table using a single INSERT command in program?
- How can we delete multiple rows from a MySQL table?
- How will you detect the condition of the end of cursor rows in a COBOL-DB2 program?
- How will you find out all the indexes which are built in a particular DB2 table?
- How to get multiple rows in a single MySQL query?
- How to obtain multiple rows in a single MySQL query?
- Update multiple rows in a single MongoDB query?
- Insert multiple rows in a single MySQL query
- Single query vs multiple queries to fetch large number of rows in SAP HANA
- Fetch specific rows from a MySQL table with duplicate column values (names)?
- Update multiple rows in a single column in MySQL?
- How can you revert all the DB2 table changes done in a COBOL-DB2 program?
- Use LIKE % to fetch multiple values in a single MySQL query