DECLARE myRaise integer
SET myRaise = 50
--declare the cursor
DECLARE mycursorname CURSOR FOR
                SELECT EID, Name, Sal
                FROM EMP
                ORDER BY Sal DESC
OPEN mycursorname

--load the cursor field values from that of the select statement
FETCH NEXT FROM mycursorname INTO @EID, @Name, @Sal
                --loop thru the cursor until we are out of rows.
WHILE @@FETCH_STATUS = 0
 BEGIN
--give the employee the raise
UPDATE Emp SET Sal = Sal + myRaise

--increment the variable by 50 for the next employee
myRaise = myRaise + 50

--move the cursor to the next record
FETCH NEXT FROM mycursorname INTO @EID, @Name, @Sal
END
CLOSE

--clean up
DEALLOCATE mycursorname
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to Oracle-PLSQL@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to