How to fetch data from an unopened cursor or opening an already opened cursor?


When we try to fetch the data from the CURSOR which is not open the query will fail. In this case the SQLCODE field of SQLCA will be populated with the DB2 error code - 501. As per the IBM documentation -501 error code states that−

“THE CURSOR IDENTIFIED IN A FETCH OR CLOSE STATEMENT IS NOT OPEN”

When we try to OPEN the cursor which is already open then the query will fail and we will get the error code as -502 in the SQLCODE field of SQLCA. As per the IBM documentation -502 error code states that−

“THE CURSOR IDENTIFIED IN AN OPEN STATEMENT IS ALREADY OPEN”

Updated on: 15-Sep-2020

106 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements