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!

SQL%ROWCOUNT

user12048986Aug 17 2010 — edited Aug 17 2010
Hi All,

I have tried to count the number of insert records that are inserted into a table using a plsql block and used SQL%ROWCOUNT but it shows only one record inserted here is the code.

DECLARE

local_variables....

Cursor c1
is
select * from temp_table;

BEGIN

IF NOT c1%ISOPEN THEN
OPEN c1;
END IF;
LOOP
FETCH c1
INTO lcoal_variables;

EXIT WHEN lc1%NOTFOUND;

if
conditions
end if;

insert into new_table (coulmns...) values (local_varible values);
end loop;

dbms_output.put_line('# of rows inserted: '|| SQL%ROWCOUNT);

IF SQL%NOTFOUND
THEN
DBMS_OUTPUT.PUT_LINE('No records Inserted');

Close C1;

END;

---------------
After this is executed the output shows that only one record is inserted but when queried the table it shows 13000 records inserted. SQL%ROWCOUNT is not showing all the inserted records


Please advice what is wrong that I am doing.

Thanks,
user12048986

Edited by: user12048986 on Aug 17, 2010 8:38 AM
This post has been answered by 513949 on Aug 17 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 14 2010
Added on Aug 17 2010
5 comments
87,936 views