do_while how can i use do while statement to delete certain rows based on the rowcount?

10 pts.
Tags:
PL/SQL
how can i use do while statement to delete certain rows based on the rowcount??

Answer Wiki

Thanks. We'll let you know when a new response is added.

“rowcount” does not really exist as part of the data. It is something generated at the moment of retrieving the data from the database, so you cannot use it to delete or update rows.

One option could be the rowid, but depending on what you want to accomplish, I think a better option is to use a cursor for loop, defining your cursor as “for update”, in order to be able to take advantage of the “where current of” condition.

Example:

<pre>create or replace procedure TEST is
cursor test_cursor is select * from your_table for update;
begin
for i in test_cursor loop
delete from your_table where current of test_cursor;
end loop;
end;</pre>

-Carlosdl

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: