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??
ASKED: October 3, 2008  8:34 PM
UPDATED: October 6, 2008  12:03 AM

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following