Here is a simple example of a cursor with the “Process Rows” step shown above in pseudocode:
declare biz_book cursor
for select * from titles
where type = ’business’
go
open biz_book
go
fetch biz_book
go
/* Look at each row in turn and perform
** various tasks based on values,
** and repeat fetches, until
** there are no more rows
*/
close biz_book
go
deallocate cursor biz_book
go
Depending on the content of the row, the user might delete the current row:
delete titles where current of biz_book
or update the current row:
update titles set title="The Rich
Executive’s Database Guide"
where current of biz_book