If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

For date between x and y
begin
insert into branchtemp(Temp_work_ID, temp_work_level, temp_date)
values(temP_work_id_seq.nextval, 5, x);
x= x+1
end for loop;

End loop;
CLOSE Temp_work_cursor;
End ;

--------------------------------------------------
What this is doing is selecting a records from a table by opening a cursor for perticular date range and then inserting records to the same table for that date range.

Now my question is if the cursor fetches all the rows which satisfies the where clause at 1st before opening it, it will not go in infinite loop right because it will have fixed number of rows before processing ?
But if the cursor is fetching records from a table after each loop

OPEN Temp_work_cursor ;
Loop
...
...
...
End loop;

In this case it will go in infinite loop right , because the next time it fetches records from the table it will have more records matching the condition and so on...

Note: this is cursor technically might not make sense because I took out other logic to make it simple.

So how doses cursor work ? Does it keep records in memory the 1st time you declare and those are the only rows it will process or does it selects from the table after each loop ?