Cursor for updating records

posted by | Leave a comment

To demonstrate how to use a cursor to update records we'll create a running total of the number of Oscars our films have won.To begin with we'll declare a couple of variables and set their default values.I think I'm probably missing something obvious, but can anyone help? I remember that it was to do with the fact that I was running an aggregate query on another aggregate query, but I can't remember why it didn't work now! Regardless, I'd like to know how to do this with a cursor! I'm trying to make reference to a field in the cursor row using "cur PO.

There are some limitations to client-side cursors: They're static and lack support for pessimistic locking.

The easiest way to declare a cursor that can be used to update records is to simply use the default cursor type: Using the code above will declare a cursor which can used to update records.

You can make things a little more obvious by explicitly stating that the cursor is to be used for updating, as shown below: This cursor can be used to update any field from the underlying data set.

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.

Leave a Reply

dating in louth lincolnshire