why not just do
UPDATE emp
   SET sal = (SELECT   sal + (ROWNUM * 50)
                  FROM emp
              ORDER BY sal desc);


On Mon, Oct 13, 2008 at 9:28 AM, NewOracleMember <[EMAIL PROTECTED]
> wrote:

>
> So far,in PL/SQL I've declared my cursor with 3 columns.I am trying to
> use an if statement to update the salary. But I am stuck.
>
> On Oct 13, 11:17 am, NewOracleMember <[EMAIL PROTECTED]>
> wrote:
> > 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