If the cursor is updatable (that is, the ReadOnly parameter is not included in the definition cursor statement), you can use the cursor to DELETEUPDATE rows from the source table of the cursor data, that is, the DELETEUPDATE operation is based on the current position of the cursor. For example: -- delete the record Declarecur_DepartCursorForSelectcDeptID, cDeptN of the current row
If the cursor is updatable (that is, the Read Only parameter is not included in the definition of the cursor statement), you can use the cursor to DELETE/UPDATE rows from the source table of the cursor data, that is, the DELETE/UPDATE operation is based on the current position of the Cursor. For example: -- DELETE the records of the current row Declare cur_Depart Cursor For Select cDeptID, cDeptN
If the cursor is updatable (that is, the Read Only parameter is not included in the definition of the cursor statement), you can use the cursor to DELETE/UPDATE rows from the source table of the cursor data ,, DELETE/UPDATE operations based on the current position of the cursor;
Example:
-- Delete the record of the current row
Declare cur_Depart Cursor
For Select cDeptID, cDeptName From Department into @ DeptID, @ DeptName
Open cur_Depart
Fetch From cur_Depart into @ DeptID, @ DeptName
Delete From Department Where current of cur_Depart
-- Update the content of the current row
Declare cur_Depart Cursor
For Select cDeptID, cDeptName From Department into @ DeptID, @ DeptName
Open cur_Depart
Fetch From cur_Depart into @ DeptID, @ DeptName
Update Department Set cDeptID = '000000' + @ DeptID Where current of cur_Depart
An Update example
Create table t1 (id int) () t1, c_update_id id from t1 c_update_idc_update_id () c_update_idc_update_id c_update_idDEALLOCATE c_update_id t1t1