Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
In a stored procedure I need to update 100 rows in a file with a batch number if the batch number is currently 0. It doesn't look like having "fetch 100 rows only" is valid on an UPDATE statement, so is there another way that I can accomplish the same thing?
Here's what my statement currently looks like:
UPDATE cscedipoh
SET ehbtch = v_batch_number
where ehbtch = 0
FETCH first 100 rows only;
Any suggestions would be greatly appreciated!
Just off the cuff, sounds like you need to use a cursor in a loop and update where current of the cursor. Either the cursor has the "for 100 rows," or use a variable that you increment as you do the fetches, and leave the loop after the 100th iteration. Either way you'll need to test for no row retrieved by the fetch and quit the loop (i.e., end-of-file).