While updating records using cursor

27-Jun-2019 10:49

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.So it is necessary to have both the fetch statement to loop-through the complete recordset.create or replace procedure student Load is v_id ID%type; v_name Name%type; v_sn stud Name%type; cursor cur_load is select * from student; begin open cur_load; loop fetch cur_load into v_id,v_name; exit when cur_load%notfound; select stud Name into v_sn from stud Load where stud ID = v_id; if(v_sn!What you have at the moment will loop through the results rows, and if it finds a row with salary equal to 1300, if then executest he following SQL: This code is updating all the records with salary 13000.Instead i want to update records having salary 1300 to the value 13000.

while updating records using cursor-16while updating records using cursor-53

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.

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.

My difficulty is that I'm having trouble finding an example of how to update a column fetched by a cursor.

Previously when I've used cursors I've retrieved values into variables, then run an update query at each step based upon these values.

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.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.My difficulty is that I'm having trouble finding an example of how to update a column fetched by a cursor.Previously when I've used cursors I've retrieved values into variables, then run an update query at each step based upon these values. On this occasion I want to update a field in the temporary table, yet I can't figure out how to do it.