DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: View updated row in PL/SQL

  1. #1
    Join Date
    Jun 2008
    Posts
    38

    View updated row in PL/SQL

    i have a PL/SQL Block that will update a row uisng FOR LOOP CURSOR and then should show the Updated row one at a time.

    Below is the code,What i m confused/want the logic to be implemented inside the FOR LOOP to show the updated row

    Code:
    begin
    	   for record in (select sal from emp where deptno='20')
    	   LOOP
    	   update emp set sal=sal + 1000 where sal=record.sal;
    	   dbms_output.put_line( record.sal );
    	   END LOOP;
    END;
    Last edited by ali560045; 05-19-2009 at 03:08 AM.

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Talking Returning it?

    Did you try returning it:
    Code:
    -- Etc --
       new_sal   NUMBER;
    BEGIN
       FOR RECORD IN (SELECT empno, sal
                        FROM emp
                       WHERE deptno = '20')
       LOOP
          UPDATE    emp
                SET sal = sal + 1000
              WHERE empno = RECORD.empno
          RETURNING sal
               INTO new_sal;
    
          DBMS_OUTPUT.put_line (new_sal);
       END LOOP;
    END;

    PS: Check out the changes to the SELECT and WHERE clauses!
    .
    Last edited by LKBrwn_DBA; 05-20-2009 at 10:50 AM.
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width