I have been assigned a task to copy data from couple of existing columns to a couple of new columns added to the table. So i thought why not use the row set positioning cursor, it reduces calls and processing improves considerably.
The only problem was that the existing columns were declared as numeric(small int and integer to be precise) and both the new columns were declared as char.
the code i put in is some wat like this
DECLARE SEL_ALL CURSOR
WITH ROWSET POSITIONING FOR
FOR UPDATE OF ID3,ID4
Here ID3 and ID4 are the new char columns, and ID1 and ID2 are supposed to be its inputs. I put in a piece of code to tally and convert numeric data to char , and am trying to update the values for ID3 and ID4 . Fetch query is as follows
FETCH NEXT ROWSET FROM SEL_ALL FOR 20 ROWS
Once inspect and tallying process is complete
the query i put in for update is
SET ID3 = :WS-ID3,
ID4 = :WS-ID4
WHERE CURRENT OF SEL_ALL FOR ROW :WS-LOOP OF ROWSET
Variable WS-LOOP is used in a perform syntax and it loops through the 20 rows fetched.
Now once i completed this and put my code to test, none of the rows get updated, if i remove the for ROW clause i get a -508, related to positioning of the row. Any inputs/help on this is welcome.