I am trying to fetch a column from a table using a cursor. But the query returns SQL -100 for the first time it fetches. When the program starts processing the next record, and inputs the next record's data into the WHERE clause, the data for the previous record gets fetched.
So i wrote OPEN,FETCH, CLOSE CURSOR steps twice in the program as shown
1) OPEN CURSOR
2) FETCH CURSOR
3) CLOSE CURSOR
4) OPEN CURSOR
5) FETCH CURSOR
6) CLOSE CURSOR
The same input is not giving output in step2 but gives output in step 5. Closing and opening the cursor makes corrects the issue, but i am not sure how this happens. Can somebody help me on this
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
No one can help given the information you've provided. We need to see a dump of the fetched row using SPUFI or whatever and all of your code relevant to the table including the DCLGEN, the cursor declaration, and all of your SQL for the OPEN and FETCH. Display the host variables immediately before each FETCH and all SQLCODEs after any SQL.