Updating a cursor

Programmers cannot control the implicit cursors and the information in it.Whenever a DML statement (INSERT, UPDATE and DELETE) is issued, an implicit cursor is associated with this statement.It is created on a SELECT Statement which returns more than one row.The syntax for creating an explicit cursor is − DECLARE c_id customers.id%type; c_name customer S.In PL/SQL, you can refer to the most recent implicit cursor as the SQL cursor, which always has attributes such as %FOUND, %ISOPEN, %NOTFOUND, and %ROWCOUNT.The SQL cursor has additional attributes, %BULK_ROWCOUNT and %BULK_EXCEPTIONS, designed for use with the FORALL statement.The input of gurus will be highly appreciated – leave it in the comments below. But to do that, we will have to grab all data for that year and most of the data will be wasted (as it is not likely for a team to have a win/lose streak for more than 20 games in a 82-game regular season).

When such an operation on a record can also be done in the PHP layer, it saves data transfer amounts as we can just return the processed aggregation/statistical result back to the PHP layer (thus eliminating the – manipulation process at the client side).

In this way, a cursor behaves very much like a queue, traversing the dataset in a FIFO (First In First Out) manner. After getting the current win/lose status and set the streak number, we continue to loop through (traverse) the remainder of the dataset.

With each loop iteration, the cursor will “point” to the next record until we break the loop or all the records are consumed.

And finally, if the current win/lose streak is the only thing we want to know from that table, why pull all the raw data? Every insertion of the record will update that table too.

But this is way too cumbersome and too error prone. As the name of this article suggests, we will see a better alternative (in my view) to solve this problem: using cursor in a Stored Procedure.

Search for updating a cursor:

updating a cursor-51updating a cursor-50updating a cursor-16

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “updating a cursor”