Oracle cursor for updating every row in same table
It may not be the best way to work with a set of data, but if you need to loop row by agonizing row (RBAR) in a T-SQL script then a cursor is one way of doing it.Note: If you are new to SQL Server and come from an Oracle background, you should know that cursors on SQL Server are different from those on Oracle.They must be created when you are executing a SELECT statement that returns more than one row.Even though the cursor stores multiple records, only one record can be processed at a time, which is called as current row.When you fetch a row the current row position moves to next row.Both implicit and explicit cursors have the same functionality, but they differ in the way they are accessed.When you execute DML statements like DELETE, INSERT, UPDATE and SELECT statements, implicit statements are created to process these statements.
For additional information on assigning values to PL/SQL variables, see "Assigning a SQL Query Result to a PL/SQL Variable".
The set of rows the cursor holds is called the These are created by default when DML statements like, INSERT, UPDATE, and DELETE statements are executed.
They are also created when a SELECT statement that returns just one row is executed.
In addition to static SQL discussed in this chapter, PL/SQL also supports dynamic SQL, which enables you to execute SQL data definition, data control, and session control statements dynamically.
See Chapter 7, "Performing SQL Operations with Native Dynamic SQL".