Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DELETE using EXECUTE IMMEDIATE and SQL%ROWCOUNT after that.

guruparanAug 8 2008 — edited Aug 12 2008

Hi All

I am trying to delete few rows from a table (In fact, there are set of tables - these table names are stored in another table, and the idea is to go through all of them and delete all rows). I am trying to put it simple here.

I am using execute immediate to delete them. When I ran the following procedure - it said `success' (and it was).

begin
  for idx in (select table_name
                   from MY_DEBUG_TABLES)
  loop
     execute immediate ('delete from '||idx.table_name)
  end loop;
end;

When I checked the table, it had no rows. Good. But, I wonder, is it possible to find the number of rows are deleted?

I put execute immediate ('dbms_output(SQL%ROWCOUNT)') after first execute immediate. It errored out.

Is there a way to find the rows deleted?

I am using Oracle 9i / Sun OS 5.2

Thanks in advance
Guru

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 9 2008
Added on Aug 8 2008
15 comments
11,871 views