While updating records using cursor


26-Mar-2020 02:46

But mere pointing isn't gonna make sense unless it can be used. This takes data from the recordset, stores it in the variable(s) provided.

so if you remove the first fetch statement the while loop won't work as there is not "FETCHED" record for manipulation, if you remove the last fetch statement, the "while" will not loop-through.

= v_name) then update stud Load set stud Name= v_name where stud ID= v_id; else insert into stud Load values(v_id,v_name); dbms_output.put_line(v_id

I can make the code work by fetching to variables, but I'd like to know how to update the field directly. Address Type = '1801' update cur PO set Current POs = (select sum(Order Quantity) - sum(Receive Quantity) from #POs) drop table #POs fetch next from cur PO end close cur PO deallocate cur PO ) from Purchase Order Line POL inner join Supplier Address SA ON POL. Supplier_ID inner join Purchase Order Header POH ON POH.

This is, why with a large dataset, the batch approach can be best.

In general I would try the set-based approach first and run it on off hours if need be.

Before I go any further: Yes, I know that cursors perform poorly compared with set-based operations.

In this particular case I'm running a cursor on a temporary table of 100 or so records, and that temporary table will always be fairly small, so performance is less crucial than flexibility.

The better question how to get rid of the cursor and try to solve your query without it.