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

Thread: Number of rows processed

  1. #1
    Join Date
    Feb 2000
    Location
    phoenix, AZ,USA
    Posts
    20
    How do I find the number of rows processed inside a pl/sql block? I want to commit the transaction only if the number of rows deleted = rows inserted into another table.

    Thanks in advance.


  2. #2
    Join Date
    Feb 2001
    Location
    Bombay,India
    Posts
    530
    Hi,
    This is Rohit ,OCP from India.
    Inside a pl/sql u can find out the number of rows processed by rowcount attribute of cursor.

    eg.
    declare
    x number;
    begin
    insert into emp_dup
    select * from emp;
    select count(*) into x from emp_dup;
    if sql%rowcount=x then
    delete from emp;
    end if;
    end;

    sql%rowcount attribute of cursor tells u how many rows have been processed.

    If any doubts please be free to write to me at
    rohitsn@hotmail.com

  3. #3
    Join Date
    Feb 2001
    Location
    Bombay,India
    Posts
    530
    Hi,
    This is Rohit ,OCP from India.Please dont refer to the earlier pl/qsl given ,it will not solve ur problem.Use the below given program which will give u the desired result.
    Inside a pl/sql u can find out the number of rows processed
    by rowcount attribute of cursor.

    declare
    new_rows number;
    old_rows number;
    begin
    select count(*) into old_rows from a;
    insert into b
    select * from a;
    new_rows:=sql%rowcount;
    if new_rows=old_rows then
    delete from a;
    commit;
    else
    dbms_output.put_line('Error in inserting rows');
    end if;
    end;
    /


    If any doubts please be free to write to me at
    rohitsn@hotmail.com

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