Cursors
If you execute a sql statement, server selects all the rows for the query and redirects to the client. How exaclty this is done by the server. First it allocates the space to collect the rows for the select, then it reuturns the rows to the client. After returning all the rows from that allocated space it releases the memory. We dont have control over the result set when we issue a select statement.

Say you want control the flow of records from the server to client one by one so that you can do some processing based on the values in some columns then we can use cursors. In cursors we have the control over the rows, you can fetch the rows one be one do your processing, once you finished your processing you can close the cursor and deallocate the memory space used by that cursor.

If we use FOR UPDATE Clause we can update the current row in the cursor using WHERE CURRENT OF clause in the update or delete statements.

Syntax
DECLARE cursor_name CURSOR FOR select statement [FOR UPDATE [ OF column_name...]]

Example
--In the following example we declare a cursor, open, do fetch until there are no more rows and close the cursor.
declare get_customers cursor for
            select customer_no, customer_name, state from customers
declare var_cust_no integer
declare var_cust_name varchar(30)
declare var_state char(2)
   open get_customers
   fetch next from get_customers into var_cust_no, var_cust_name, var_State
   while @@fetch_Status = 0
   begin
          print var_cust_no
          print var_cust_name
          print var_state
          fetch next from get_customers into var_cust_no, var_cust_name, var_State
   end
   close get_customers
deallicate get_customers