Database cursors allow row by row processing to occur within a stored
procedure.
create procedure proc_upd_commiss as
declare @inv_id integer,
@sales_rep_id integer
declare cursor1 cursor for
select inv_id,sales_rep_id
from invoice
open cursor1
fetch cursor1 into @inv_id,@sales_rep_id
while (@@sqlstatus=0)
begin
update employee
set commiss_tot = commiss_tot + 15
where emp_id = @sales_rep_id
fetch cursor1 into @inv_id,@sales_rep_id
end
close cursor1
return
go
|
|